#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