fopen with file location

Poonamol's Avatar, Join Date: Mar 2010
Go4Expert Member
Hi,

I am creating/opening a file using,

FILE *file = fopen(" C:\\ABC\\Poo.txt","w+");
if(file == NULL)
printf("un sucessful");
else
printf("sucessful");

I am able to create a file name poo.txt on C:\ABC folder.

Now I used,
#define PATH "C:\\ABC\\"
FILE *file = fopen(" PATH+Poo.txt","w+");
OR
#define PATH "C:\\ABC"
FILE *file = fopen(" PATH\\Poo.txt","w+");
if(file == NULL)
........

How can I use PATH constant with file name in fopen?

Help me out ASAP.
Thanks in advance.
0
karthigayan's Avatar, Join Date: Feb 2010
Go4Expert Member
I tried this in linux machine.We can do this .

You have to mention like the following ,

Code:
        FILE *file=fopen(PATH"/file.txt","r+");
Don't place the PATH inside the double quotes , because what ever inside the double quotes will treated as a string.
0
Poonamol's Avatar, Join Date: Mar 2010
Go4Expert Member
Thank you so much for the reply.