Structures shouldn't give you a headache.... structures are very simple things. I think you have a headache because you think the struct will do a lot more than it does.
I'm not sure I understand what you're trying to do though, so apologies if I missed the point.
You have
Wordstruct: a struct which contains a char array and an int
WordList: An array of 25 these structs
So to copy the words from InputString to Wordlist you'll have to strcpy one element at a time.
Code:
strcpy(WordList[0].Word, strtok(InputString, " "));
WordList[0].length = strlen(WordList[0].Word);
for(i=1; i<9; i++)
{
strcpy(WordList[i].Word, strtok(NULL, " "));
WordList[i].length = strlen(WordList[i].Word);
}
You can't take a char array and assign it to an array of a different type. Nor can you do
Code:
struct WordStruct myws = "some string";
The compiler doesn't know you mean "copy the string into the char array and store the length in the int". How could it?