#include <stdio.h>
#include <cstdlib>
rec();
main()
{
int a, fact;
char q, n, y;
printf("\nEnter any number ");
scanf("%d", & a);
fact = rec(a);
printf("Factorial value = %d\n", fact);
printf("do you want to exit.....(y/n):");
scanf("%s" ,&q);
if (q == 'n')
{
system("cls");
main();
}
else
return 0;
}
rec(int x)
{
int f;
if (x == 1)
return 1;
else
f = x * rec(x - 1);
return f;
}
我使用的代码块,但我不知道如何清除屏幕。我搜索后发现在头文件#include<cstdlib>
内的system("cls");
,但它显示错误cstdlib: no such file of directory
。我该怎么办 ?如何从简单的C程序中清除屏幕?
如果有疑问,请确实访问这些链接,要知道哪个函数属于哪个头文件或哪个头文件有哪个函数:-) [Alphabetical Index](http://pubs.opengroup.org/onlinepubs/ 009695399/idx/index.html)和[Headers Index](http://pubs.opengroup.org/onlinepubs/009695399/idx/headers.html) – 2013-02-27 02:59:10
'main()' - >'int main(void)'和'rec();' - >'int rec(int x);' – 2017-03-05 05:31:30