## c language: I cannot find the output file.

What is wrong with my code?

Code:
#include <stdio.h>

int
main(int argc, char *argv[])
{
int i=0;
FILE *fp;
char fname[100];

sprintf(fname,"%04X.txt",i);
fp=fopen("fname", "w");
fprintf(fp, "hello world!\n");
fclose(fp);
}

 PhysOrg.com science news on PhysOrg.com >> Heat-related deaths in Manhattan projected to rise>> Dire outlook despite global warming 'pause': study>> Sea level influenced tropical climate during the last ice age

Recognitions:
Homework Help
 Quote by nenyan What is wrong with my code? Code: #include int main(int argc, char *argv[]) { int i=0; FILE *fp; char fname[100]; sprintf(fname,"%04X.txt",i); fp=fopen("fname", "w"); fprintf(fp, "hello world!\n"); fclose(fp); }
Hi nenyan!

Can you find a file named "fname" (literally)?

 Or, in order to generate the file with the file name that you are expecting, you need to remove the double-quotes from around "fname" in the open statement so that you use the variable name fname and not the literal string "fname"

## c language: I cannot find the output file.

 Quote by I like Serena Hi nenyan! Can you find a file named "fname" (literally)?
yes....I can....

 Quote by gsal Or, in order to generate the file with the file name that you are expecting, you need to remove the double-quotes from around "fname" in the open statement so that you use the variable name fname and not the literal string "fname"
Thank you very much!