Execute main, it will ask for input.
Store input in the argbuf.
Then, use strwrd to split argbuf into tokens
Yet, it says "Error: incompatible types in assignment of char * to char[200]"
I cannot figure out why..
#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;
}