2
strtok 기능을 모방하려고했지만 세그먼트 화 오류가 발생했습니다. 제발 도와주세요.이 코드의 잘못된 점은 무엇입니까?
이#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char argv[])
{
int i=0;
char c[]="get the hell out of here";
char *p;
char *temp=(char *)malloc(100);
while(c[i]!='\0')
{
if(c[i]!=' ')
{
*temp=c[i];
temp++;
i++;
}
else
{
*temp='\0';
printf("printing tokenn");
puts(temp);
i++;
temp="";
}
}
return 0;
}
* void main * !!!! – dreamlax
@dreamlax void main은 실제로 괜찮습니다. Shashank는'# include '를 코드로 옮겨서 제대로 포맷 할 수 있습니까? 그리고'temp = "";'줄로 무엇을 의미합니까? – Vyktor
@Vyktor :'void main'이 실제로 작동 할 수는 있지만 합법적이지는 않습니다. – jamesdlin