為何! RE : 記憶體區段錯誤! Segmentation fault (core dumped)
#include <string.h>
#include <stdio.h>
int main(){
int n;
char s[200]={'\0'};
while(scanf("%s", &s)!=EOF){
for(n = 0 ; n <= strlen(s) ; n++){
s[n] -= 7;
}
printf("%s\n", s);
}
return 0;
}
求解釋,拜託了!各位大大們
為何! RE : 記憶體區段錯誤! Segmentation fault (core dumped)
#include
#include
int main(){
int n;
char s[200]={'\0'};
while(scanf("%s", &s)!=EOF){
for(n = 0 ; n <= strlen(s) ; n++){
s[n] -= 7;
}
printf("%s\n", s);
}
return 0;
}
求解釋,拜託了!各位大大們
如果輸入字串超過200呢?