creator.c
来自「C.Game.Programming.For.Dummies.原码」· C语言 代码 · 共 37 行
C
37 行
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
void 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!");
fclose(myfile);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?