mainを実行すると、入力を求められます。
入力をargbufに保存します。
次に、strwrdを使用してargbufをトークンに分割します
それでも、「エラー:char*から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;
}