#29850: 有人知道這是為什麼嗎? (C語言)


imcoolooc@gmail.com (username = ?)


NA:系統呼叫了 abort 函式! *** stack smashing detected ***: terminated Aborted (core dumped)

 

#include <stdio.h>
#include <string.h>
int main() {
    char buf[80];
    scanf("%s", buf);
    int al = strlen(buf);
    int td;
    for (int a=0; a < al; a++) {
        td = (int)(buf[a]);
        printf("%c", (td - 7));

    }


    return 0;
}


 

#29853: Re:有人知道這是為什麼嗎? (C語言)


cges30901 (cges30901)


    char buf[80];


看到stack smashing detected就要想到buffer overflow。你的buf開太小了,如果改成700就會AC了