下記コードでは,入力した文字列を切り分けて表示はされるのですが、segmentationfaultになるのはなぜでしょうか・・・
#include<stdio.h> #include<unistd.h> #include <string.h> int main(){ char command[1000]; char *p; printf(">"); fgets(command,200,stdin); char *tp = strtok(command," "); printf("%s\n", tp); while(tp!=NULL){ tp=strtok(NULL, " "); printf("%s\n", tp); } }
よろしくおねがいいたします
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。