please help to debug this

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2009
Posts: 4
Reputation: osgiedeprof is an unknown quantity at this point 
Solved Threads: 0
osgiedeprof osgiedeprof is offline Offline
Newbie Poster

please help to debug this

 
0
  #1
30 Days Ago
Please can anyone out there help me see the problem with this piece of code? I’ve tried running it on the visual studio compiler
But either get warnings or undesired output.
I supposed the code to be a little dictionary that compares
Inputs with some set of predefined ones and then output
It’s meaning if matches are found. Otherwise print NOT FOUND
And ask user to research.
Here’s the snippet:

  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10. bool chance = true;
  11. char *Dictionary[][2] ={
  12. "God", "osalobua",
  13. "welcome", "obokhian",
  14. "jesus", "ijesu christy",
  15. "come", "lare",
  16. "friend", "ose",
  17. "school", "Esuku",
  18. "go", "kpa",
  19. "sun", "oven",
  20. "man", "okpia",
  21. "woman", "okhuo",
  22. "child", "omo",
  23. "baby", "omomo"
  24.  
  25. };
  26.  
  27. while(chance)
  28. {
  29. int i;
  30. char word[20];
  31. cout << "Enter a word and i'll tell\n"
  32. <<"you about it in edo language: ";
  33. cin >> word;
  34.  
  35. for(i = 0; *Dictionary[i][0]; i++){
  36. if(!strcmp(Dictionary[i][0], word)){
  37. cout <<"\n"<<word <<" is translated"
  38. <<" as => " <<Dictionary[i][1]
  39. <<" \nin edo language ";
  40. break;
  41. }
  42. }
  43. if(!*Dictionary[i][0]){
  44. cout <<"sorry! there's no matching word like"<<word;
  45. cout <<"will you like to search again?(y or n)";
  46. string restart;
  47. cin>>restart;
  48. if(restart != "y")
  49. chance = false;
  50. }
  51. }
  52.  
  53. return 0;
  54. }

here's the warning message from the compiler:

1>LINK : warning LNK4076: invalid incremental status file 'G:\arraysnd veators\Debug\arraysnd veators.ilk'; linking nonincrementally
1>Embedding manifest...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>LINK : warning LNK4076: invalid incremental status file 'G:\arraysnd veators\Debug\arraysnd veators.ilk'; linking nonincrementally
1>Build log was saved at "file://g:\arraysnd veators\arraysnd veators\Debug\BuildLog.htm"
1>arraysnd veators - 0 error(s), 2 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,678
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 262
Lerner Lerner is offline Offline
Posting Virtuoso
 
0
  #2
30 Days Ago
You use the STL string class later in your program so why not use it here, too:
string Dictionary[12][2] ={ {"God", "osalobua"}, etc
and here:
string word;

Line 35 could then be:
for(i = 0; i < 12; ++i)

and Line 36 is simply
if(word == Dictionary[i][0])

with line 41 being :
if(i == 12)

You never use a vector, so why include the vector header?
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC