Slow but sure and I am finally close. Below is a function I am calling from a menu. It is to convert a sentence for English to Pig Latin. I have not found where I went wrong yet (any help would be appreciated). To let you know where I am at, here is the a sample input and a sampl of whay I get returned right now:
input- bring me the butter
out put- ingbray ebay ebay utterbay
Code: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("%s", temp); tokenPtr=strtok(NULL, " "); } printf("\n\n"); return 0; }![]()
Thanks for any help or advice!



LinkBack URL
About LinkBacks




