c语言编程为什么出现exe停止工作

#include<stdio.h>
void main()
{
int i=0,base,num[32];
long int n; char c;
printf("Input num:");
scanf("%ld",&n);
printf("Input base:");
scanf("%d",&base);
for(i=0;;i++)
{
if(n=0)
break;
num[i]=n%base;
n=n/base;

}
c=i;
for(i=0;i<c;i++)
printf("%f ",num[c-i]);
printf("\n");
}

将十进制转化为其他进制的问题

你的这种情况叫做 runtime error (运行时错误)。


在 Windows 7 上这样提示:


在 Windows XP 上这样提示:


runtime  error (运行时错误)就是程序运行到一半,程序就崩溃了。

比如说:

①除以零

②数组越界:int a[3]; a[10000000]=10;

③指针越界:int * p; p=(int *)malloc(5 * sizeof(int)); *(p+1000000)=10;

④使用已经释放的空间:int * p; p=(int *)malloc(5 * sizeof(int));free(p); *p=10;

⑤数组开得太大,超出了栈的范围,造成栈溢出:int a[100000000]

温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2017-10-08
if(n=0)
break;
num[i]=n%base;
n=n/base;
判断是 == 不是= ,一个等号表示赋值,所以n=0,而这个循环会一直下去 死循环了追问

还是不行。。

本回答被提问者采纳
第2个回答  2012-11-12
在程序的结尾加上getchar(),阻塞一下。要不然结果运算出控制台就关闭了,所以看不到结果
第3个回答  2012-11-12
看看你的程序里面的scanf语句中有没有“&”这个符号,(举个例子:scanf("%d",&a);这里的&表示取地址,如果没有这个符号会出现你讲的这个现象)
第4个回答  2012-11-13
yntax error : missing ';' before '<'
d:\学习系统2012\c语言文件系统\vbxxb\g.cpp(1) : error C2501: 'include' : missing storage-class or type specifiers
d:\学习系统2012\c语言文件系统\vbxxb\g.cpp(1) : error C2143: syntax error : missing ';' before '<'
d:\学习系统2012\c语言文件系统\vbxxb\g.cpp(3) : error C2143: syntax error : missing ';' before '{'
d:\学习系统2012\c语言文件系统\vbxxb\g.cpp(3) : error C2447: missing function header (old-style formal list?)
执行 cl.exe 时出错.
g.obj - 1 error(s), 0 warning(s)

zhe这么多的 错误
相似回答