Scan a sentence with space into *char array in C
<p>I'm not good at using C language. Here is my dumb question. Now I am trying to get input from users, which may have spaces. And what I need to do is to split this sentence using space as delimiter and then put each fragment into char* array. <br>Ex:<br>
Assuming I have <code>char* result[10];</code>, and the input is: <code>Good morning John</code>. The output should be <code>result[0]="Good";</code> <code>result[1]="morning";</code> <code>result[2]="John";</code><br>I have already tried <code>scanf("%[^\n]",input);</code> and <code>gets(input);</code> Yet it is still hard to deal with String in C. And also I have tried <code>strtok</code>, but it seems that it only replaced the space by <code>NULL</code>. Hence the result will be <code>GoodNULLmorningNULLJohn</code>. Obviously it's not what I want. Please help my dumb question. Thanks.<br>
<strong>Edit:</strong><br>
This is what I don't understand when using <code>strtok</code>. Here is a test code.
The <code>substr</code> still displayed <code>Hello there</code>. It seems <code>subtok</code> only replace a <code>null</code> at the space position. Thus, I can't use the <code>substr</code> in an <code>if</code> statement.</p>

<pre><code>int main()
{
    int i=0;
    char* substr;
    char str[] = "Hello there";
    substr = strtok(str," ");

    if(substr=="Hello"){
        printf("YES!!!!!!!!!!");
    }

    printf("%s\n",substr);

    for(i=0;i&lt;11;i++){
        printf("%c", substr[i]);
    }

    printf("\n");
    system("pause");
    return 0; 
}
</code></pre>