请告诉我,这里出了什么问题,它可以编译,但当我输入数字时控制台崩溃。我不知道接下来要写什么,我只会写一些东西来使我的帖子成为可能。
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{
unsigned int i,l,p,w;
printf("Enter natural number excluding 0: ");
scanf("%d",l);
p = 1;
for(i=1;i<=l;i++)
{
p=p*i;
}
w=p;
printf("\nFactorial of entered number %d",w);
return 0;
}
最佳答案
scanf("%d",l);
需要插入l
的地址,即&l
。
您还应该使用 %u
表示无符号整数,而不是 %d
。
关于c - 为什么它不起作用(Dev C++ 中的 C Lang),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23375975/