一个关于C语言编程的问题

来源:百度知道 编辑:UC知道 时间:2024/06/03 05:37:19
RT 以下为我所编的程序

/* program 1.2 your second C program */
#include <stdio.h>

int main(void)
{
printf("If at first you don\'t succeed, try, try, try again!");
system("pause");
return 0;
}

加下划线的那句被提示错误而且提示如下:
E:\C++\1.2 try again.cpp In function `int main()':
E:\C++\1.2 try again.cpp `system' undeclared (first use this function)

请高人指点如何处理(PS:这个程序一开始我顺利运行过一次,但保存后就出现上述问题。)

根据楼主第二个错误提示E:\C++\1.2 try again.cpp `system' undeclared (first use this function) ,应该是你没有写入包含system函数的头文件,一般system函数包含在stdlib.h的头文件中,楼主可以试试在程序的第一行加一个#include<stdlib.h>就可以了

system()命令需要头文件<stdlib.h>,楼主不妨加进去试试,但是不知道为什么开始楼主编译会通过 。

在最开头加个
#include <windows.h>

就可以了,祝你好运!