小编haz*_*uit的帖子

我的C程序一直在崩溃

我有这个小程序,我需要用字母表替换我输入的任何字符串,所以a = 01,b = 02,n = 14,7 = 07 ...例如,如果我输入ab36c作为输出我应该得到01 02 03 06 03

当我在另一台计算机上编译这一切时,一切正常,现在当我在我的电脑程序崩溃时运行它,我仍然可以输入我的字符串,但当我按Enter键获得结果(输出)时,它显示program.exe已停止工作.什么错了?

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <windows.h>
#include <stdlib.h>
#include <ctype.h>
//#define SIMBOLU_SKAITS 100

int main(){    
    char text[200];
    char *s2;
    char simboli[36]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t',
                     'u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9'};
    char morze[36][3]={"01","02","03","04","05","06","07","08","09","10","11","12","13",
                 "14","15","16","17","18","19","20","21","22","23","24","25","26",
                 "00","01","02","03","04","05","06","07","08","09"};
    int i, j, garums;

    gets(text);

    garums=strlen(text);

    for (i=0;i<=garums;i++){ 
        for (j=0; j<=36;j++)
            if( text[i]==simboli[j]){
                strcat(s2,morze[j]);
                strcat(s2," ");

            break;
            }
    }

    puts(s2);

    scanf("%c");
}
Run Code Online (Sandbox Code Playgroud)

c crash

2
推荐指数
1
解决办法
1510
查看次数

标签 统计

c ×1

crash ×1