hiscores.c

来自「C.Game.Programming.For.Dummies.原码」· C语言 代码 · 共 26 行

C
26 行
字号
#include <stdio.h>

void main()
{
    FILE *scores;
    int s[10] = { 1000, 990, 985, 960,
        955, 950, 945, 945, 945, 930 };
    int x;

    scores=fopen("scores.dat","w");
    if(scores==NULL)
    {
        puts("Error creating file");
    }
    else
    {
        for(x=0;x<10;x++)
        {
            fprintf(scores,"%i\n",s[x]);
        }
        fclose(scores);
        puts("High scores saved to disk!");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?