turning a string sentence into pig Latin

Newbie Member
1Mar2010,06:32   #1
lbartz's Avatar
I have to take a sentence, and turn it into pig latin.

I can get the sentence to come in no problem, but when I go to deciper each word into the Pig Latin, it looks at the whole sentence string instead of just one word at a time. I also have to take into account punctuation. Should I be using the substring, or the .find or what?? I'm stumped.

Skilled contributor
1Mar2010,08:10   #2
techgeek.in's Avatar
i m giving u the word extracting program..once u can extract all the words in a sentence then u can handle each words one by one...

Code:
# include<stdio.h>
# include<conio.h>
# include<malloc.h>
# include<string.h>

void main()
{
int i=0,j=0,k=0;
char temp[10];
char p[50]; //maximum length of the sentence
char q[10][10]; //maximum number of words it can hold is 10 and each having maximum size 10
clrscr();

gets(p);   //get the string


while(p[i]!='\0')
{
if(p[i]==' ')
{
temp[j]='\0';
j=0;
strcpy(q[k],temp);
++k;
++i;
}
else
{
temp[j]=p[i];
j++;
i++;
}
}

temp[j]='\0';
strcpy(q[k],temp);


for(i=0;i<=k;i++)
puts(q[i]);       //finally the 2d array contains all the words.



getch();  //run the program by giving sample senetence "this is my book"
}
Newbie Member
8Mar2010,06:52   #3
lbartz's Avatar
Thanks. I will try incorporating this code into my program.
Wish me luck!

lbartz
Skilled contributor
8Mar2010,19:37   #4
techgeek.in's Avatar
Best of luck..Try ur best..I have shown u the path...Rest is up to u...