실행에 할당 할 때 호환되지 않는 유형이 입력되면 입력을 요청합니다.char *를 char [200]
argbuf에 입력 내용을 저장하십시오.
그런 다음, 사용 strwrd이
그러나 토큰으로 argbuf 분할, 그것이 말하는 "오류 : 문자의 할당에서 호환되지 않는 유형 *는 char [200]"
나는 ..
이유를 알아낼 수 없습니다#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char argbuf[200];//used to store input
char *strwrd(char *s, char *buf, size_t len, char *delim){
s += strcspn(s, delim);
int n = strcspn(s, delim); /* count the span (spn) of bytes in */
if (len-1 < n) /* the complement (c) of *delim */
n = len-1;
memcpy(buf, s, n);
buf[n] = 0;
s += n;
return (*s == 0) ? NULL : s;
}
int main(){
fgets(argbuf, sizeof(argbuf), stdin);
char token[10][20];
int index;
for (index = 0; index < 10; index++) {
argbuf = strwrd(argbuf, token[index], sizeof(token[index]), " \t");
if (argbuf == NULL)
break;
}
return 1;
}
저를 상기시켜 줘서 고마워요. 나는 항상 질문에 대답하려고 노력하지만 ... 프로그래밍에 익숙하지 않다. – mabeiyi
가능한 [C에서 char *와 char \ [\]의 차이점 (http://stackoverflow.com/questions/10054271/) char-and-char-in-c) 차이점 – netcoder
잘 모르겠습니다. 나는 그것을하지 않았다 – mabeiyi