I'm writing a pig latin program and am having problems moving onto the next word and printing the words. I have to print from the first vowel onto the end of the word and then from the beginning of the word to the first vowel including the vowel itself.
#include <stdio.h>
#include <string.h>
char sentence[81];
char *pointer;
int a = 0;
void find_first_vowel(void)
{
while (sentence[a] != 'A' && sentence[a] != 'a' &&
sentence[a] != 'E' && sentence[a] != 'e' &&
sentence[a] != 'I' && sentence[a] != 'i' &&
sentence[a] != 'O' && sentence[a] != 'o' &&
sentence[a] != 'U' && sentence[a] != 'u' &&
a < strlen(sentence))
{
printf("%c", sentence[a]);
a = a + 1;
}
return;
}
void main(void)
{
int j, startword, endword;
printf("Welcome to the ultimate pig latin translator\n");
printf("Please enter a phrase up to 80 characters or 'stop' to end: \n\n");
while(strcmp(sentence, "Stop") != 0 && strcmp(sentence, "STOP") != 0 && strcmp(sentence, "stop") != 0)
{
printf("\nEnter a phrase or 'stop' to end: \n");
gets(sentence);
printf("\nThe sentence you inputted is: \n %s \n\n", sentence);
pointer = strtok(sentence, " ");
while (pointer != NULL)
{
pointer = strtok(NULL, " ");
}
find_first_vowel();
printf("%c", pointer);
for(j=a+1;j<strlen(sentence);j++)
{
printf("%c", sentence[j]);
}
for(j=0; j<a; j++)
{
printf("%cay", sentence[j]);
}
}
getche();
}