What you denote as "sentence" is usually called a
word. So I understand that you want to find the n-th word in a string and return its position, i.e. character index within the string. Correct?
We don't give you code for your homework, but seeing that you are at the very beginning of your study, a couple of hints might stear you in the right direction.
First, I formatted your code with indentation, so that it's easier to read. And I used the amber "code" tag of the edit box to let it appear with this nice amber background and in a monospaced font. In your next question you are expected to do that by yourself.
Now, take a look at your main function. Does it call your WordIndex function? No. So how in the world could that work?
Next, let's take a look at your WordIndex function. It returns type void, i.e. it doesn't return anything. Shouldn't WordIndex find the n-th word and return its index? Then I would expect WordIndex to be defined as:
int WordIndex (char *s)
I removed the size parameter as it is redundant. C-strings have a NULL-terminator at their end, so you read s character by character until you find '\0' or simply 0.
And now the interesting stuff. The code inside WordIndex is a little messed up. I want you to find those things by yourself. The little secret weapon we are going to use is the following: Group the code into little packages of 2 to 10 lines. Each package should do something that can easily be described in a comment. Precede each group by that comment, like this:
char* p;
for(p = s; *p; ++p){
if (*p == ' ')
break;
}
By describing exactly what each group of lines is supposed to do, we can discuss any "glitches" in your code step by step -- and you will even find most of them on your own.