473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

pig latin

I'm trying to convert english to pig latin but it's giving me errors can somebody please help?!?




Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using std::cout;
  3. using std::cin;
  4. using std::endl;
  5.  
  6. #include <cstring> // prototype for strtok
  7. using std::strtok; 
  8. using std::strlen;
  9. void ConverToPigLatin(char word [],int size);
  10. int main()
  11. {
  12.  
  13. char sentence[100];
  14. char *tokenPtr;
  15. void ConverToPigLatin(char word [],int size);
  16.  
  17. cout<< "Enter a Phrase:";
  18.  
  19. cin>>sentence;
  20. cin.getline ( sentence , 100); 
  21. tokenPtr= strtok (sentence, " ");
  22.  
  23.  
  24.  
  25.  
  26. // begin tokenization of sentence
  27.  
  28.  
  29. // continue tokenizing sentence until tokenPtr becomes NULL
  30. while ( tokenPtr != NULL ) 
  31.  ConvertToPigLatin(tokenPtr);
  32. {
  33.  
  34.  
  35.  
  36. tokenPtr = strtok(NULL, " " ); // get next token 
  37. } // end while
  38.  
  39.  
  40. return 0; // indicates successful termination
  41. } // end main
  42. for (int i = 1; i <strlen (word); i++);
  43. cout << word [i];
  44. cout << sentence [0];
  45.  
  46. cout<< "ay";
  47.  
  48.  
  49. cout << "\n Pig Latin phrase: " << sentence << endl;
  50. }
Jul 30 '07 #1
2 2408
sicarie
4,677 Expert Mod 4TB
valechale-

Not a big deal, I'm editing your post now, but please make sure to use code tags (they're to the right when you start or edit a post) in the future, as well as posting the errors (they usually contain a line number or keyword that help debugging as well. Please have a look at the Posting Guidelines as they contain all of these rules and more.

Thanks!

sicarie

PS - moving from Articles to Forum
Jul 30 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
Line 31 needs to be after the { of the while loop
Lines 40 and 41 say they are the end of main but there is more
code after them
Line 42 has a semi-colon which makes the loop do nothing
Line 42 needs a variablke word that has not beed defined
Line 50 is a closing brace. Probably you forgot the opening brace of the for loop

These are all obvious coding bugs. Try to have stuff like this cleared up before you post.
Jul 30 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Laurent | last post by:
Hi, I have an XML file with this text in it: <price>10 &#x20AC;</price> (just an example) My input and output encodings are Latin 1 (ISO-8859-1). When PHP parses it, the characterdata...
4
by: Uwe Mayer | last post by:
Hi, in a PyQt application I'm writing, the user can select a filename with a FileDialog. Then I would like to open this file. This works fine if there are no "special symbols" in the filename,...
17
by: thinkfirst | last post by:
Hello CIWAH ... I want to propose full internationalization of three related websites: http://africadatabase.org/ http://people.africadatabase.org/ http://institutions.africadatabase.org/ My...
10
by: Arne | last post by:
Since I am Swedish, I write website content mostly in Swedish language and using charset iso-8859-1. I have (just for testing) tried to use utf-8 on a test page (...
1
by: Markus Ernst | last post by:
Hi I wrote a function that "normalizes" strings for use in URLs in a UTF-8 encoded content administration application. After having removed the accents from latin characters I try to remove all...
9
by: Andy | last post by:
I am trying to write a for loop that will print all the ISO-Latin characters to a database. However: I am not sure exactly how to go about printing the ISO-Latin character set. Would anyone be...
10
by: NoelByron | last post by:
Hi! I'm struggling with the conversion of a UTF-8 string to latin-1. As far as I know the way to go is to decode the UTF-8 string to unicode and then encode it back again to latin-1? So I...
10
by: ahoway | last post by:
I am having problems entering a sentence for translating into pig latin. It is set up now to read the entire sentence as one word. I would like to know how to look at each word in the sentence so...
1
by: Chris Curvey | last post by:
Hey all, I'm trying to write something that will "fail fast" if one of my users gives me non-latin-1 characters. So I tried this: u'\x80' I would have thought that that should have raised...
5
by: | last post by:
How can I convert a string read from a database containing unicode literals, such as "Fr\u00f8ya" to the latin-1 equivalent, "Frøya"? I have tried variations around "Fr\u00f8ya".decode('latin-1')...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.