函数“系统”的隐式声明在C99中无效

时间:2019-10-01 17:02:21

标签: c xcode c99

我已经阅读了有关此问题的其他问题,但我仍然不明白如何为这两个功能创建原型。我当前正在使用Xcode。

出现问题的两个功能是exitsystem

#include <stdio.h>

void main()
{
    FILE *fp;
    char ename[30], ans;
    int t_score;

    fp = fopen("/Users/mmu/Desktop/Program Design/Assignment/Assignment 3/Assignment 3/surveyIn.txt", "a");

    if (fp == 0)
    {
        printf("File could not be opened!\nProgram stopped.\n");
        exit(1);
    }
    else
    {
        do
        {
            fflush(stdin);
            printf("Name: ");
            gets(ename);
            printf("Test mark: ");
            scanf("%d", &t_score);
            fprintf(fp, "%s %d\n", ename, t_score);
            fflush(stdin);
            printf("Do you want to continue (Y/N)? \n");
            scanf("%c", &ans);
        }
        while (ans=='y' || ans=='Y');
    }

    fclose(fp);
    system("pause");
}

输出是这样的:

Name: warning: this program uses gets(), which is unsafe.
Paul
Test mark: 50
Do you want to continue (Y/N)? 
sh: pause: command not found
Program ended with exit code: 0

0 个答案:

没有答案