Segmentation fault到底怎麼解TAT
#include<stdio.h>
#include<ctype.h>
char arr[10000];
int main(void)
{
while(getline(arr)!=EOF){
int n=0;
int space=0;
while(arr[n]!='\0'){
if(isspace(arr[n]))space++;
arr[n]=0;
n++;
}
printf("%d\n", space+1);
}
return 0;
}
while(getline(arr)!=EOF){
getline()是什麼函式?我沒用過,編譯時產生錯誤訊息 too few arguments to function call, expected 3, have 1,我網路上查到的getline確實需要三個參數:https://en.cppreference.com/w/c/experimental/dynamic/getline