creating directories...?

P

Patrik

I know how to read/write files using iostram, but I can't figure out
how to create a directory. Say I wan't to create a directory called
"/home/work/outfiles", how do I do that? I'm running red hat linux.

Rgs,

Patrik
 
S

Sharad Kala

Patrik said:
I know how to read/write files using iostram, but I can't figure out
how to create a directory. Say I wan't to create a directory called
"/home/work/outfiles", how do I do that? I'm running red hat linux.

You need to resort to some platform specific API, standard C++ does not
define it.
 
G

Guest

Patrik said:
I know how to read/write files using iostram, but I can't figure out
how to create a directory. Say I wan't to create a directory called
"/home/work/outfiles", how do I do that? I'm running red hat linux.

In any Posix environment:
#include <unistd.h>
//int mkdir(const char *pathname, mode_t mode);

- Dario
 
O

osmium

Patrik said:
I know how to read/write files using iostram, but I can't figure out
how to create a directory. Say I wan't to create a directory called
"/home/work/outfiles", how do I do that? I'm running red hat linux.

Using system() will give your program pretty much the same powers as a human
would have WRT the operating system. There may be a better way too,
included as part of the API.
 
V

Victor Bazarov

Patrik said:
I know how to read/write files using iostram, but I can't figure out
how to create a directory. Say I wan't to create a directory called
"/home/work/outfiles", how do I do that? I'm running red hat linux.

There is no OS-independent way because not all OSes have directories.
You should consult your OS programming manual (or book). In most
cases a simple

system("mkdir /home/work/outfiles");

should do it, but what specifically to put in double quotes and what
the effect of that is going to be, is OS-specific.

V
 
P

Prateek R Karandikar

I know how to read/write files using iostram, but I can't figure out
how to create a directory. Say I wan't to create a directory called
"/home/work/outfiles", how do I do that? I'm running red hat linux.

Rgs,

Patrik

"directory" ??? No such thing exists in Standard C++.

-- --
Abstraction is selective ignorance.
-Andrew Koenig
-- --
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,174
Messages
2,570,941
Members
47,476
Latest member
blackwatermelon

Latest Threads

Top