Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WHY IS MY TRANSLATOR NOT TRANSLATING!!! this is for c + + #include #include #include using namespace std; const int minWords = 2 0 0

WHY IS MY TRANSLATOR NOT TRANSLATING!!! this is for c++
#include
#include
#include
using namespace std;
const int minWords =200;
const int MaxWord =400;
const int MaxInput =600;
struct LoadAnimals
{
char english[MaxWord];
char spanish[MaxWord];
};
void TranslateAnimals(const char* input, const LoadAnimals dict[], int size, char* output)
{
for (int j =0; j < size; ++j)
{
if (strcmp(input, dict[j].english)==0)
{
strcpy(output, dict[j].spanish);
return;
}
}
strcpy(output, input);
}
bool printTrace = true;
void trace (string message)
{
if (printTrace)
cout << message << endl;
}
int main()
{
cout << "Farm Animal Translator!" << endl;
ifstream englishFile;
ifstream spanishFile;
englishFile.open("english.txt");
spanishFile.open("spanish.txt");
if (!englishFile && !spanishFile)
{
cout << "Error opening files." << endl;
return 42;
}
if (!englishFile)
{
cout << "Error opening englishFile." << endl;
return 44;
}
if (!spanishFile)
{
cout << "Error opening spanishFile." << endl;
return 46;
}
trace ("open both files");
//struct for inFile.txt
LoadAnimals dict[minWords];
int Count =0;
while (Count < minWords && englishFile >> dict[Count].english)
{
++Count;
}
cout << "After loading english file cout is"<< Count << endl;
Count ==29;
while (Count < minWords && spanishFile >> dict[Count].spanish)
{
++Count;
}
char english[MaxInput];
char spanish[MaxWord];
cout << "Enter a short sentence in English: ";
cin.getline(english, sizeof(english));
char Word[MaxWord];
int WordIndex =0;
for (int i =0; i <= strlen(english); ++i)
{
char character = english[i];
if (character ==''|| character =='\0')
{
Word[WordIndex]='\0';
if (WordIndex >0)
{
TranslateAnimals(Word, dict, Count, spanish);
cout << "The Spanish translation of: \""<< Word <<"\" is: "<< spanish << endl;
cout << "English: "<< Word <<"\tSpanish: "<< spanish << endl;
WordIndex =0;
}
}
else
{
Word[WordIndex++]= character;
}
}
cout << "Thank you!" << endl;
englishFile.close();
spanishFile.close();
return 0;
}
the program compiles. i know theres some issues because i keep playing around with it but please help

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago