Since the program can't know in advance whether a given name in Names will have 2 or three tokens, I would use an array of char * store each token as it was developed, and an index to keep track of how many tokens found in each string. After each string has been tokenized the string, then look at the value of the index. If the value of the index indicates there were two tokens found, then there is no middle name, so enter null instead in the array of middle names.
declare array of tokens;
declare index and set it to 0
see if there is a token
while there are more tokens to find
{
add token to token array at appropriate index
increment index
}
add firtst element in array of tokens to array of first names
if index equals 1 //meaning only two names found
add null to array of middle names.
add second element of array of tokens to array of last names
else
add second element in array of tokens to array of middle names
add third element in array of tokens to array of last names Also note that you can't use the == to compare null terminated strings, you must use strcmp(), or a function related to strcmp() like strncmp();