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:

#include <iostream>
#include <string>
#include <vector>
using namespace std;


int main()
{
	bool chance = true;
	char *Dictionary[][2] ={
		"God", "osalobua",
		"welcome", "obokhian",
		"jesus", "ijesu christy",
		"come", "lare",
		"friend", "ose",
		"school", "Esuku",
		"go", "kpa",
		"sun", "oven",
		"man", "okpia",
		"woman", "okhuo",
		"child", "omo",
		"baby", "omomo"

	};

	while(chance)
	{
		int i;
		char word[20];
		cout << "Enter a word and i'll tell\n" 
			<<"you about it in edo language:  ";
		cin >> word;

		for(i = 0; *Dictionary[i][0]; i++){
			if(!strcmp(Dictionary[i][0], word)){
				cout <<"\n"<<word <<" is translated"
					<<" as => " <<Dictionary[i][1]
				<<" \nin edo language ";
		        break;
			}
		}
		if(!*Dictionary[i][0]){
		cout <<"sorry! there's no matching word like"<<word;
		cout <<"will you like to search again?(y or n)";
		string restart;
		cin>>restart;
		if(restart != "y")
			chance = false;
		}
	}

	return 0;
}

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 ==========

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[0])

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

You never use a vector, so why include the vector header?

This article has been dead for over six months. Start a new discussion instead.