473,386 Members | 1,748 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,386 software developers and data experts.

New to programming having trouble with Piglatin code

3
Expand|Select|Wrap|Line Numbers
  1. /* C 
  2.  * program 6.cpp
  3.  * This program you can play tic-tac-toe. 
  4.  *
  5.  *   ---------------------------------------------
  6.  *  |                                             |
  7.  *  |---------------------------------------------|
  8.  *  |         |/     \    |         / | \         |
  9.  *  |        /|        \  |       /   |  \        |
  10.  *  |  0 () / |         \ |      /    |   \ () 0  |
  11.  *  | -+-/ /   ----------- -----------     \ \-+- |
  12.  *  |  |  *   |           |\   /      |     *  |  |
  13.  *  | / \     |           |  *        |       / \ |
  14.  *  |         |           |           |           |
  15.  *  |---------------------------------------------|
  16.  *  |                                             |
  17.  *   ---------------------------------------------
  18.  *
  19.  */    
  20.  
  21. #include <stdio.h>
  22. #include <string.h>
  23.  
  24. /* Data */
  25. char sentence[80];
  26. char *psentence;
  27. char word, vletter, vword, cword;
  28. int startword, endword, i;
  29. char letters[12];
  30.  
  31.  
  32. /* Function */
  33.  
  34.  
  35. void vowel (void)
  36. {
  37.  
  38.     sentence [word] != 'a' &&
  39.     sentence [word] != 'A' &&
  40.     sentence [word] != 'e'  &&
  41.     sentence [word] != 'E'  &&
  42.     sentence [word] != 'i'  &&
  43.     sentence [word] != 'I'  &&
  44.     sentence [word] != 'o' &&
  45.     sentence [word] != 'O' &&
  46.     sentence [word] != 'u' &&
  47.     sentence [word] != 'U';
  48.  
  49.      }           
  50.  
  51.  
  52.  
  53. main (void)
  54. {
  55. printf ("This program will translate one English sentence at a time into pig latin.\n\n");
  56.  
  57. printf ("Please type in a sentence less than 80 character.\n");
  58. printf ("Enter only words and do not use punctuation.\n" );
  59. printf ("To exit please enter stop.\n");
  60.  
  61. printf ("Please enter you sentence:\n");
  62. gets(sentence);
  63. printf ("\nYou entered:\n%s\n\n", sentence);
  64.  
  65. printf ("This is you sentence in piglatin: ");
  66.  
  67.  
  68.  
  69. while (strcmp(sentence,"stop") != 0)
  70.     {
  71.  
  72. /*    letters[12] = ('a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U', 'y', 'Y');*/
  73.     vword = 'nay';
  74.     cword = 'ay';
  75.     startword = 0;
  76.     endword = startword;
  77.     psentence = strtok (sentence, " ");
  78.  
  79.         while (psentence[endword]!= NULL)   /* while more words */
  80.          {
  81.           printf ("%s ", psentence);
  82.           vletter = psentence[startword];
  83.           psentence = strtok (NULL, " ");   /* replaces ‘  ’ with ‘\0’ */
  84.           }
  85.  /*           
  86.             While (vletter != Null){
  87.                for (int i = 0; i < 12; i++) {
  88.                if (vletter == letters[i]) { 
  89.                     strcat(psentence+letters[1],vword);  
  90.                       return true; };
  91.                       strcat(psentence+letters[i],cword);
  92.                          return false;
  93.                                             } 
  94.                                             } */
  95. }
  96. scanf("tell me what happen");
  97. }
Dec 4 '07 #1
4 3608
Shashi Sadasivan
1,435 Expert 1GB
Hi,
Could you please let us know where you are facing trouble?

Is this using the .Net framework (do you have to convert it to .Net) or is it a C/C++ related query?
Dec 4 '07 #2
dcrdvd
3
I am new into programming and this has been a real big task. I was able for the program to read my input but I am having trouble with the first letter being a vowel or consonant and then adding the correct extension. Thanks any help would be greatly appreaciated.
Dec 4 '07 #3
sicarie
4,677 Expert Mod 4TB
First you need to develop the logic for this part - create your algorithm. How would you formulate this if you were given a sheet of paper and a pencil and had to write out the directions for a small child (a compiler is like a small child - very literal, and limited to exactly what you tell it)?

Does your code do this? Does it do it incorrectly? Honestly, I didn't look, after I saw your title dealing with pig latin and the first comment dealing with something about tic tac toe.
Dec 5 '07 #4
dcrdvd
3
Hi,
Could you please let us know where you are facing trouble?

Is this using the .Net framework (do you have to convert it to .Net) or is it a C/C++ related query?

It is c related, Thanks
Dec 5 '07 #5

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

Similar topics

1
by: beckers | last post by:
How do you write a function to request a word from the keyboard and translate the word into piglatin?
134
by: evolnet.regular | last post by:
I've been utilising C for lots of small and a few medium-sized personal projects over the course of the past decade, and I've realised lately just how little progress it's made since then. I've...
6
by: @(none) | last post by:
Hi, I need to learn the necessary and sufficient C programming knowledge in order to be able to implement number theory and graph theory algorithms (as RSA or Dijkstra algorithms). No system...
4
by: Corey Dyke | last post by:
K here's what happened. For my English project at DeVry, I had to design a website for a company of my choice. So since my dad has been after me for years to do one for him, I decided to finally...
0
by: Patrice de Boisgrollier | last post by:
Hello I'm having trouble under windows 2000 dealing with programming a ping in a Visual C++ 6 environment My problem is that my code is based on a code sampl from Microsoft that is found in...
9
by: John Salerno | last post by:
There is an article on oreilly.net's OnLamp site called "The World's Most Maintainable Programming Language" (http://www.oreillynet.com/onlamp/blog/2006/03/the_worlds_most_maintainable_p.html). ...
30
by: pavan | last post by:
Is there a modern (OO, garbage collected etc...) programming language that can server as a good alternative for C for system programming. I wouldn't want to compromise too much on performance.
6
by: CapMaster | last post by:
I'm having some trouble programming the game of life. In the version my teacher gave us, it involves a class with a private grid variable for the game. Here's the class she gave us: .. const int...
5
by: JoeC | last post by:
I am a self taught programmer and I am starting to get better and create larger and more complex projects. Mostly I write games because they keep me interested. I have done some reading with...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.