Hello
I am using CodeBlocks to learn C programming and this is my first post in this forum. I am successfully able to read files using fopen, but when I try to write to a text file within the executable folder using fopen function - I get a null pointer in return.
When I execute the code below:
- a file with the name HELLOWORLD.TXT is created in the same folder as the executable.
- I have checked "File name extensions" under View in Windows Explorer and the file name is HELLOWORLD.txt and NOT HELLOWORLD.txt.txt.
- but then the if block in the following code is executed.
FILE *fp;
char s[80];
fp=fopen("HELLOWORLD.TXT", "w");
if(fp==NULL)
{
puts("Cannot Create File");
exit(1);
}
Could you kindly assist me to resolve this issue?