*****My code gets its input from this step.
Code:
else if (choice == 3) {
/*Gather user's input */
printf("\nYou have chosen to convert a sentence to all lowercase letters and count thewords\n"
"Enter the sentence: \t");
gets( sentence );
/*Call the function to convert the whole sentence to lowercase and count thenumber of words */
lowercase_string( &sentence);
countSentence( &sentence);
}/* End if statement */
****This Is the part in which Im getting trouble
/* Prompts user to enter a sentence and convert it tolowercase and count the number of words */
void countSentence (char *sentence)
void lowercase_string (char*)
{
printf ("The original string is %s\n", sentence);
lowercase_string (sentence);
printf("The string in lowercase is\"%s\"\n", sentence);
}
void lowercase_string(char *sentence)
{
while(*sentence)
{
if(*sentence>= 'A' && *sentence <= 'Z')
{
*sentence= *sentence + 32;
}
sentence++;
}
}
/*Definenew variables*/
char *tokenPtr; // Saying syntax error
int i;
intcounter = 0;
{
tokenPtr= strtok( sentence, " \n"); /* Space before new line */
/*continue tokenizing sentence until tokenPtr becomes NULL */
while( tokenPtr )
{
++counter;
tokenPtr = strtok( NULL, "\n" ); /* get the next token */ Saying syntax error
}/* end while */
printf("\nThetotal number of words is %d\n\n", counter);
} /* End of sentence*/Saying Fatal error unexpected end