#include #include #include int main() { FILE *myfile; char c; myfile = fopen("alive.txt","r"); if(myfile) /* the file exists */ { puts("ALIVE.TXT already exists!"); printf("Overwrite it? [Y/N]"); c = toupper(getchar()); if(c!='Y') { puts("Okay. Goodbye"); fclose(myfile); exit(0); } } myfile = fopen("alive.txt","w"); if(myfile==NULL) { puts("Some kind of error"); exit(0); } fprintf(myfile,"I created a file! It's alive!\n"); fclose(myfile); return(0); }