#25789: 我在Xcode測試很多次都不知道哪裡錯?


Xcode (Xcode)


#include <stdio.h>

#include <string.h>

 

int main() {

    char g[100];

    int o, l;

    scanf("%s", g);

 

    l = (int)(strlen(g));

    for(o = 0; o < l; o++){

        printf("%c", g[o] - 7);

    }

    printf(" \n");

    return 0;

}

 

 

 

 

系統呼叫了 abort 函式!

*** stack smashing detected ***:  terminated
Aborted (core dumped)
???
#25791: Re:我在Xcode測試很多次都不知道哪裡錯?


fire5386 (becaidorz)


字串的陣列開的不夠大,像這種題目直接開到10000也不會記憶體用量過多