|
-
October 26th, 2011, 12:09 PM
#1
Newbie problem, fopen
Hello,
I am hoping someone can help with a problem I am having. I need to open a file to write an int and a float to it. So, I have been trying to build up my understanding to do this, so I figured I would try and get a small prohram working first. But that plan isn't going so well.
The program is
Code:
/* fopen example */
#include <stdio.h>
int main ()
{
FILE * pFile;
pFile = fopen ("myfile.txt","w");
if (pFile!=NULL)
{
fputs ("fopen example",pFile);
fclose (pFile);
}
return 0;
}
Now, can I ask, do I need to create an empty file called myfile? Or shoukd the program do that? If I do need to make the file, how does the program know where to find it??
I have been reading the documentation, but I don't really find answers to these questions, they all assume a specific amount of understand to begin with it seems.
Any help or advice would be fantastic! I want to learn how to do this, I don't want anyone to do it for me, but I do need to have some things explained.
Also, is there an error in this program??
I hope that's cool.
Thanks in advance.
Seán
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|