Mode | Meaning of Mode | During Inexistence of file |
---|---|---|
r / rb | Open text/binary file for reading. | If the file does not exist, fopen() returns NULL. |
w / wb | Open text/binary file for writing. | If the file exists, its contents are overwritten. If the file does not exist, it will be created. |
a / ab | Open text/binary for append. i.e, Data is added to end of file. | If the file does not exists, it will be created. |
r+ / rb+ | Open text/binary file for both reading and writing. | If the file does not exist, fopen() returns NULL. |
w+ / wb+ | Open text/binary file for both reading and writing. | If the file exists, its contents are overwritten. If the file does not exist, it will be created. |
#include<stdio.h> main() { FILE *fp; fp=fopen("ccit.txt","r"); if(fp = = NULL) printf("File dos'nt exists..."); else { printf("File exists..."); fclose(fp); } }
File exists...