Hello

I was wondering whether is it possible to create a .txt file or check if a .txt file exists inside the folder earlier defined as a path.
Basically I have a path :

#define some_little_file "/User/Joey/Desktop/"

and I would like to create and manipulate a txt file there.
Is it even possible??
Merry Christmas btw guys much love !!

Yup ...

if (file = fopen(file_name, "r"))
{
       printf("Exists");
       fclose(file);
}

Merry Christmas to u too ...

Edited 5 Years Ago by Shankye: n/a

Yup ...

if (file = fopen(file_name, "r"))
{
       printf("Exists");
       fclose(file);
}

Merry Christmas to u too ...

Thanks for your answer

I know how to work with files in c, but my problem is that I need to create a file on that path. My source is on a external disk or whatever and I want it to create a txt file on my desktop. I just need to know whether is it possible without using cmd arg.

Your program can create a file anywhere it wiches as long as it has the permissions needed to do that. You can't create a file in a directory where you don't have write permissions.

Or are you trying to ask if you can put the path in a file and read the path from that file. For example, if you have file named ./path that contains "/User/Joey/Desktop/". The answer is again yes, you can easily do that. Just read the file into a variable the use that variable in the call to fopen()

Comments
Gr8 guy !!

Your program can create a file anywhere it wiches as long as it has the permissions needed to do that. You can't create a file in a directory where you don't have write permissions.

Or are you trying to ask if you can put the path in a file and read the path from that file. For example, if you have file named ./path that contains "/User/Joey/Desktop/". The answer is again yes, you can easily do that. Just read the file into a variable the use that variable in the call to fopen()

Thank you ancient dragon. Much respect !!

This question has already been answered. Start a new discussion instead.