Hello,
You should have
Code:
memcpy(array + loop, cmd_str + i , j);
since array[loop] is not a pointer, it is the value of the actual element, thus *(array+loop)
Haven't checked if the logic is correct
But do not use memcpy for this.
I am sure you will get a lot "don't use gets()" comments so just go ahead and change it to fgets(). See the forums FAQ or google fgets().
But in any case, I will show you how to use strtok(). You use it always similar (passing the string on the first call and NULL on the second) usually:
Code:
char* tok;
tok = strtok(cmd_str, " "); //you pass your string and the delimiter, which is space for u
while(tok != NULL)
{
printf("%s\n", tok); //you print your token, one every line
tok = strtok(NULL, " "); //you pass NULL now to continue on the rest of the string!
}
this is the example used here. It is the basic use.