...
Code Block | ||
---|---|---|
| ||
/* ... */ FILE *fp = fopen("foo.txt"file_name,"r"); if (!fp) { /* file does not exist */ fp = fopen("foo.txt"file_name,"w"); /* ... */ fclose(fp); } else { /* file exists */ fclose(fp); } /* ... */ |
...
Code Block | ||
---|---|---|
| ||
/* ... */ FILE *fptr; errno_t res = fopen_s(&fptr,"foo.txt"file_name, "r"); if (res != 0) { /* file does not exist */ res = fopen_s(&fptr,"foo.txt"file_name, "w"); /* ... */ fclose(fptr); } else { fclose(fptr); } /* ... */ |
...