c - 测试 - 运行时错误 SIGSEGV

标签 c runtime-error

请帮助我Here is a problem of Codechef 。这是我的提交内容:

#include <stdio.h>

#define M 60

int main()
{
    int i,arr[M],input;
    int s=0;
    puts("Input:");
    for(i=0;;i++){
        scanf("%d",&input);
        if(input==42){
            scanf("%d");
            break;
        }
        else{
            arr[i]=input;
            s++;
            }
        }
    puts("Output:");
    for(i=0;i<s;i++){
        printf("%d\n",arr[i]);
    }
    return 0;
}

当我创建代码时,它在 GCC 4.9.2 上成功运行,但是当我提交此代码时,Codechef 说它有运行时错误。我尝试过但找不到错误。 所以 请帮我找出错误...

最佳答案

第二个 scanf 中的变量丢失

关于c - 测试 - 运行时错误 SIGSEGV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50823353/

相关文章:

c - pthreads:使用多线程计算连续素数

c - 如何检查数组中有多少元素为空?

C编程。如何制作打印字符串的方法

python - 我的应用程序无法运行,因为我缺少 MSVCR90.dll,我该怎么办?

google-app-engine - 在 GAE 下使用 http.Server 时运行时崩溃

c - 如何生成预处理的 C 代码

在内核空间创建共享内存段?

c# - ASP.NET : getting 'currentStyle' is null or not an object when adding webpanel dynamicly

c++ - 运行时错误: "*** glibc detected ***: double free or corruption (out)"

c - 当我调用 atoi() 函数时出现程序段错误