Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

[Xcode] Problem in FILE

Hello everybody

I have a problem in creation of file, for example, when I create:

FILE* fichier = NULL;

fichier = fopen("test.txt", "w");

I don't find test.txt in the file project

please help me where I can find it

And thank you so much

OS X Yosemite (10.10.3)

Posted on May 29, 2015 3:24 AM

Reply
Question marked as Best reply

Posted on May 29, 2015 6:40 AM

Salut Kati,

When using POSIX functions like fopen(), you should always specify the full path to the file. If you use just a relative path or filename, as above, then the path to the file is relative to whatever the current working directory of the app happens to be. That directory is not obvious and can change. If you are building and running from the command line, then these kinds of paths are easier to use. But when using Xcode, you must always specify the full path. I suggest keeping such test files in /tmp or /Users/Shared.

2 replies
Question marked as Best reply

May 29, 2015 6:40 AM in response to Kati Ais

Salut Kati,

When using POSIX functions like fopen(), you should always specify the full path to the file. If you use just a relative path or filename, as above, then the path to the file is relative to whatever the current working directory of the app happens to be. That directory is not obvious and can change. If you are building and running from the command line, then these kinds of paths are easier to use. But when using Xcode, you must always specify the full path. I suggest keeping such test files in /tmp or /Users/Shared.

[Xcode] Problem in FILE

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.