| New Reply |
c language: I cannot find the output file. |
Share Thread | Thread Tools |
| Aug4-12, 02:30 AM | #1 |
|
|
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);
}
|
| Aug4-12, 03:58 AM | #2 |
|
Recognitions:
|
![]() Can you find a file named "fname" (literally)? |
| Aug4-12, 06:13 AM | #3 |
|
|
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"
|
| Aug4-12, 10:23 AM | #4 |
|
|
c language: I cannot find the output file. |
| Aug4-12, 10:23 AM | #5 |
|
|
|
| New Reply |
| Thread Tools | |
Similar Threads for: c language: I cannot find the output file.
|
||||
| Thread | Forum | Replies | ||
| Python and file output | Engineering, Comp Sci, & Technology Homework | 3 | ||
| Java Program Input from file, output to file(s) | Engineering, Comp Sci, & Technology Homework | 31 | ||
| MCNP output file interpretation | Nuclear Engineering | 3 | ||
| file output | Programming & Comp Sci | 4 | ||
| Fortran output file | Programming & Comp Sci | 1 | ||