AlexTardif
Programmer
Hi,
I need some help about creating text files. I use Windows 98 and I want to create text files in different directories. These directories are "under" the program directory.
I was thinking doing this way :
#include <stdio.h>
#define N 300
void main(void)
{
FILE *fp;
/* that's where my question comes...
char fname[N] = "/path1/path2/../pathN/fileXXXX.ext";
or
char fname[N] = "\path1\path2\..\pathN\fileXXXX.ext";
or
char fname[N] = "path1/path2/../pathN/fileXXXX.ext";
or
char fname[N] = "path1\path2\..\pathN\fileXXXX.ext";
or
char fname[N] = what else??? */
fp = fopen(fname, "w"
/* file writing ... and treatment */
}
By the way, all the paths are already created.
I tried the four declaration types and the files are never created, fopen() always return NULL.
I have some paths and some files that are longer than the xxxxxxxx.xxx format, does it matter in C? What do I do wrong?
I have another question (always in Windows) : Can I use MS-DOS commands in my C programs? And how can I call it? Example :
cd pathx in C : cd("pathx" ????
rmdir pathy in C : rmdir("pathy"
Thank you for all the answers!
Alex
I need some help about creating text files. I use Windows 98 and I want to create text files in different directories. These directories are "under" the program directory.
I was thinking doing this way :
#include <stdio.h>
#define N 300
void main(void)
{
FILE *fp;
/* that's where my question comes...
char fname[N] = "/path1/path2/../pathN/fileXXXX.ext";
or
char fname[N] = "\path1\path2\..\pathN\fileXXXX.ext";
or
char fname[N] = "path1/path2/../pathN/fileXXXX.ext";
or
char fname[N] = "path1\path2\..\pathN\fileXXXX.ext";
or
char fname[N] = what else??? */
fp = fopen(fname, "w"
/* file writing ... and treatment */
}
By the way, all the paths are already created.
I tried the four declaration types and the files are never created, fopen() always return NULL.
I have some paths and some files that are longer than the xxxxxxxx.xxx format, does it matter in C? What do I do wrong?
I have another question (always in Windows) : Can I use MS-DOS commands in my C programs? And how can I call it? Example :
cd pathx in C : cd("pathx" ????
rmdir pathy in C : rmdir("pathy"
Thank you for all the answers!
Alex