您的位置:

c语言引用变量提示停止工作,C语言停止工作

本文目录一览:

求助大神为什么我用c语言编写的程序运行的时候显示程序停止工作?

scanf语句和printf语句都有错误。

正确的代码如下:

scanf("%lf",fRadius);

printf("圆的面积为: %lf\n",fResult);

是%lf,而不是%If,scanf语句中,,fRadius在""后面,而不是在""里面。

C语言出现“已停止工作”的问题。

楼上是坑,把别人的问题发到你这里。或者是直接复制的别人的答案。

scanf("%d",b);

这句话要加上符号啊~~

改成scanf("%d",b);

而且算法也不对!

诶,还是让我帮你重写一份吧。。

# includestdio.h

int main()

{

int a[15],b,i,temp=1;

printf("请输入要求的阶乘数:");

scanf("%d",b);

printf("\n");

for(i=0;i=b-1;i++)

a[i]=i+1;

for(i=1;i=b;i++)//这种事情i要从0开始,否则无论什么情况a[0]总要*进去,导致结果永远是0

temp=temp*a[i];

printf("%d",temp);

return 0;

}

一运行C语言程序 就提示程序已经停止工作

试试重新建立工程,编译以下空代码的程序:

int main()

{

}

如果这个空代码编译运行不出问题,说明你的程序在调用scanf或者调用指针时候有内存上的错误出现。(仔细查看代码中的scanf和指针调用时的内存使用错误,也可以把所有用到指针和scanf的地方先屏蔽,找出哪个地方内存分配不对)。

如果这个空代码运行也出问题,说明是你编译器有问题。

本人用C语言编程,可是出现了一运行就停止工作。怎么回事,求大腿们帮帮眼看看哪里出问题啦。。。

取地址符呢?吃了?

另外,\n也吃了...

对你程序的改进

#includestdio.h

int main (void)

{

int i = 0;

struct contractinfor

{

char num[9];

char name[8];

int chinese;

int english;

int mash;

int sum;

int score;

}studern[3];//为了方便调试,这里就用一个小的数

while (i3)//建议使用While循环

{

printf("\n-----\n Please put the %d student number:\n", i+1);

scanf("%s",studern[i].num);

printf(" Please put the student name:\n");

scanf("%s",studern[i].name);

printf(" Please put the student Chinese:\n");

scanf("%d",studern[i].chinese);

printf(" Please put the student English:\n");

scanf("%d",studern[i].english);

printf(" Please put the student Mash:\n");

scanf("%d",studern[i].mash);

studern[i].sum=studern[i].chinese+studern[i].english+studern[i].mash;

studern[i].score=studern[i].sum/3;

i++;

}

i = 0;

while (i3)//输出

{

printf( "\n-----\nThe student number:\t%s\n",studern[i].num);//'\t'表示制表符

printf( "The student name:\t%s\n",studern[i].name);

printf( "The student sum:\t%d\n",studern[i].sum);

printf( "The student score:\t%d\n",studern[i].score);

i++;

}

return 0;

}

输出结果:

在运行C语言程序时为什么就提示程序已停止工作?

C语言中函数的调用中,参数传递,只能传递数值。如果只是将数值传递过去(接收者是形参),在子函数中变化,形参的变化,不会影响到实参数据的内容。

C中,每定义一个变量,系统都会在内存中给其分配一个空间用来存储数据。而这个空间的编号就是这个变量的地址。当我们将这个地址传递到子函数中,子函数在操作数据时,就会改变这个地址中的数据,这样,实参的数据是会发生变化。

而你程序中,传递的是a b本身的值(可能是0,可能是1,可能是任意的数),scanf()将这两个值当作地址去操作,因此会产生系统错误,导致程序运行停止。

C语言是一种计算机程序设计语言,它既具有高级语言的特点,又具有汇编语言的特点。它由美国贝尔研究所的D.M.Ritchie于1972年推出,1978年后,C语言已先后被移植到大、中、小及微型机上,它可以作为工作系统设计语言,编写系统应用程序,也可以作为应用程序设计语言,编写不依赖计算机硬件的应用程序。

它的应用范围广泛,具备很强的数据处理能力,不仅仅是在软件开发上,而且各类科研都需要用到C语言,适于编写系统软件,三维,二维图形和动画,具体应用比如单片机以及嵌入式系统开发。

C语言程序运行时显示编程.exe停止工作,怎么办?

这种情况叫做 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]