I'm working on another program, which creates sentences from randomly chosen words.... I just started and have this little part of code, and it just crashes the whole thing... Cannot find the reason why....
If anybody can tell me why, I'd be really grateful.
Code:
int main()
{
char noun[] = "bank cat mouse car lady";
char verb[] = "wetted kissed swum walked skipped";
char preposition[] = "to from over under on";
char article[] = "the a one some any";
char *current_noun;
char *current_verb;
char *current_prep;
char *current_art;
int i = 1;
int number = 0;
long ltime = 0;
unsigned stime = 0;
noun_ptr1[0] = current_noun = noun;
verb_ptr[0] = current_verb = verb;
prep_ptr[0] = current_prep = preposition;
art_ptr[0] = current_art = article;
while ( (current_noun = strchr(current_noun, ' ')) != NULL)
{
*current_noun++ = '\0';
noun_ptr1[i++] = current_noun;
}
printf("%s, %s, %s, %s, %s\n", noun_ptr1[1], noun_ptr1[2], noun_ptr1[3], noun_ptr1[4], noun_ptr1[5]);
return 0;
}