Page 1 of 1

PostPosted: Thu May 11, 2006 7:20 am
by Maria
I am sorry to post this twice but I think I had posted it to the wrong forum (development discussion).

------------------------------------------------------------------
Hi
I just started on Andy Harris' Palm programming book and am stuck at Chapter 2, challenge no. 3, "Ask the user for a word and convert that word into pig latin by extracting the first letter and adding it to the end of the word with "ay". For example, if the user enters "PocketC", the program shoudl return "ocketCPay". Don't worry about words that begin with vowels.

My problem is :-

1. Extracting a letter - I can only do so if I know the number of letters in the word the user chooses. If my number is more than the number of letters, it doesn't work.

2. Adding to the end of the word - I am completely stumped. I tried various codes but nothing seem to work.

Don't laugh too hard - here's what I have so far :-

string str;
main();
clear();

puts("StringLibrary\n");
while(str=gets("Please enter a word:")){
puts("nRight10=" + strright(str.10));
wait();
}
} //end main

Any help would be greatly appreciated.


Thanks!

PostPosted: Mon Jun 05, 2006 4:37 pm
by dbbotkin
Try strlen(string) to get the length of the word.