Standard way of dealing with directories

J

josegomez

Hi!
I want to produce a number of output filenames, which contain a
directory part, and a file aprt (e.g., /home/user1/dir1/file.dat would
be one). I have the directory in one char array, and the filename in a
different one. Using strncat and strncpy one can manage that, but i
would like the code do intelligently deal with the forward (UNIX) and
backwards-slash (Windows) directory naming convention. Is there a
standard way of creating this things, rather strtok-ing the string for
/ and substituting for \ with a compiler conditional?

Thanks
Jose
 
D

David Resnick

Hi!
I want to produce a number of output filenames, which contain a
directory part, and a file aprt (e.g., /home/user1/dir1/file.dat would
be one). I have the directory in one char array, and the filename in a
different one. Using strncat and strncpy one can manage that, but i
would like the code do intelligently deal with the forward (UNIX) and
backwards-slash (Windows) directory naming convention. Is there a
standard way of creating this things, rather strtok-ing the string for
/ and substituting for \ with a compiler conditional?

Thanks
Jose

Hi,

Questions like this aren't really on topic on comp.lang.c.
But since you are asking about multiple OS where to go is sometimes
tricky -- perhaps comp.programming?

<OT> I think that forward slashes are likely to work from within a
program --
if you aren't displaying to user who has expectations based on what
works from the command line, it may just work. Give it a try. May be
wrong, it has been a while since I used Win for programming </OT>


-David
 

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,166
Messages
2,570,902
Members
47,442
Latest member
KevinLocki

Latest Threads

Top