473,466 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

`word` is undefined in pig latin generator

2 New Member
I need some serious help!! I am supposed to convert an english sentence to pig latin.... This is what I have so far but everytime I go to compile it it says that word is undeclared!! can someone please help me..



Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using std::cout;
  3. using std::cin;
  4. using std::endl;
  5.  
  6.  
  7. #include <cstring> // prototype for strtok
  8. using std::strtok;                        
  9.  
  10.  
  11. int main()
  12. {
  13.  
  14.     char sentence[100];
  15. char *tokenPtr;
  16.  
  17.  
  18. cout<< "Enter a Phrase:";
  19. void  ConverToPigLatin(char word [],int size);
  20.  
  21.  
  22.  
  23. cin>>sentence;
  24.     cin.getline ( sentence , 100);     
  25.  
  26. void ConvertToPigLatin (char word[],int size);
  27. cin>> strlen(word);
  28. for (int i = 1; i < strlen(word); i++)
  29. cout << word [i];
  30.  
  31.  
  32.  
  33.            cout << word [0];
  34.  
  35.  
  36.            cout<< "ay";
  37.  
  38.  
  39.           // begin tokenization of sentence
  40.  
  41.  
  42.    // continue tokenizing sentence until tokenPtr becomes NULL
  43.    while ( tokenPtr != NULL ) 
  44.  
  45.    {
  46.  
  47.       cout << tokenPtr << NULL;
  48.  
  49.       tokenPtr = strtok(NULL, " " ); // get next token 
  50.    } // end while
  51.  
  52.    cout << "\n Pig Latin phrase: " << sentence << endl;
  53.  
  54.    return 0; // indicates successful termination
  55. } // end main
Jul 27 '07 #1
2 2859
pbmods
5,821 Recognized Expert Expert
Changed thread title to better describe the problem (did you know that threads whose titles contain three words or less actually get FEWER responses?).

Heya, valechale. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

I'm going to go ahead and move this thread to the C forum, where our resident Experts will be better able to help you out.
Jul 27 '07 #2
Banfa
9,065 Recognized Expert Moderator Expert
Lines 19 and 26
Both declare a function ConverToPigLatin
Expand|Select|Wrap|Line Numbers
  1. void  ConverToPigLatin(char word [],int size);
  2.  
that takes char * and int parameters. However this function is never defined (and luckily never called)

Lines 27 - 33
Several uses of the variable word (which from context should be an array of char or a pointer to an array of char) however this variable is never declared anywhere (in the same way that for instance sentence is) so you get undeclared variable errors.
Jul 27 '07 #3

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

Similar topics

6
by: Andy Jacobs | last post by:
Hi All I've written a little CMS with a WYSIWYG editor from www.interactivetools.com. Everything works ok until they try and copy text from MS Word. When they do this, apostrophes change to a...
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...
19
by: E. Robert Tisdale | last post by:
In the context of the comp.lang.c newsgroup, the term "undefined behavior" actually refers to behavior not defined by the ANSI/ISO C 9 standard. Specifically, it is *not* true that "anything can...
1
by: smith flyers | last post by:
i got the following error when compiling the codes.. the name 'word' does not exist in the class or namespace 'SimpleMath.Pig' Can anyone troubleshoot on this . Thank you ...
12
by: enak | last post by:
I have found some code that shows how to convert an html form to Word. The message said to simply put the following in the Page_load: Response.ContentType = "application/ms-word"...
3
by: Jose | last post by:
Hello. I have a word document vinculed with a .csv file. How open this document for merge with mi csv file from vb 2003? Thanks a lot.
5
by: krisbee1983 | last post by:
Hello to all, I'm beginer in learning Python I wish somebody help me with solving this problem. I would like to read all text files wchich are in some folder. For this text files I need to make...
2
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Is it possible to convert a microsoft word document to pdf in .net code. If anyone has done this before, please let me know.
4
hemantbasva
by: hemantbasva | last post by:
We have designed an aspx page having five ajax tab in it. the data of first four are designed on page whereas for the fifth tab it renders a user control named MYDOMAIN. in the tab container's even...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.