Sorry about that --not sure what I managed to do to lose my formatting. Here is the complete program I am working on. As mentioned in the previous post, the pig() function is my trouble spot. Here is the a sample input and a sample of what I get returned right now:
input- bring me the butter
out put- ingbray ebay ebay utterbay
Code:
# include <stdio.h>
# include <string.h>
int name();
int pig();
int izzle();
main()
{
int y;
while ( y != 4)
{
printf("Welcome to the word game!\n");
printf("Please select from the following list:\n");
printf("1. Name Game\n 2. Pig Latin\n 3. My Game\n 4. Exit\n");
scanf("%d", & y);
fflush(stdin);
if (y==1)
name();
else
if (y==2)
pig();
else
if (y==3)
izzle();
}
}
int name()
{
char word[40];
char bword[40];
char fword[40];
char mword[40];
char oword[40];
int h=1;
int l=1;
int w=1;
printf("Enter your name\n");
scanf("%s", word);
sscanf(word, "%s", oword);
mword[0]='M';
fword[0]= 'F';
bword[0]= 'B';
printf("\n\n%s!\n%s, %s bo", word,word,word);
for (h=1; (bword[h]=word[h]) !='\0'; h++){
printf("%s Bonana fanna fo", bword);}
for (l=1; (fword[l]=bword[l]) !='\0'; l++) {
printf("%s\nFee fy mo", fword);}
for (w=1; (mword[w]=fword[w]) !='\0'; w++) {
printf("%s, %s!\n\n", mword, oword); }
}
int pig()
{
char sent[150];
char part[40];
char temp[40];
char *tokenPtr;
char vowel []= "aeiou";
char *ptrloc;
int llen=0;
int tlen=0;
int k=0;
printf("Please enter a sentence\n");
gets(sent);
tokenPtr=strtok(sent, " ");
while (tokenPtr !=NULL)
{
sscanf(tokenPtr, "%s", part);
ptrloc=strpbrk(part, vowel);
tlen=strlen(part);
llen=strlen(ptrloc);
for (k; k < (tlen-llen); k++)
{
temp[k]=part[k];
}
temp [ (tlen-llen)]='\0';
printf(" %s", ptrloc);
printf("%say", temp);
tokenPtr=strtok(NULL, " ");
}
printf("\n\n");
return 0;
}
int izzle()
{
char dumb[150];
char *tokenPtr;
printf("Please enter a sentence:\n");
gets(dumb);
tokenPtr = strtok(dumb, " ");
while(tokenPtr != NULL)
{
printf(" %sizzle ", tokenPtr);
tokenPtr=strtok(NULL, " ");
}
printf("\n");
return 0;
}
Again any help is appreciated !