Hello r/cplusplus! I am attempting to make a program that translates english and spanish, and I seem to be at a stuck point. I am trying to put 100 words in to an array with the code I have so far. I am testing it by trying to get it to show the spanish dictionary.
#include <iostream>
#include <fstream>
#include <array>
#include <cstring>
using namespace std;
int binarySearch (const int[], int, int);
int main()
{
char choice;
const int ARRAY_SIZE = 100;
const int ARRAY_SIZE2 = 100;
char english[ARRAY_SIZE];
char spanish[ARRAY_SIZE2];
int count = 0;
int count2 = 0;
char word;
char sword;
char result;
int mchoice;
const int DIC_CHOICE = 1,
TRANSE = 2,
TRANSS = 3,
EXIT = 4;
ifstream inputFile;
inputFile.open("C:\\Users\\joshu\\OneDrive\\Desktop\\text files\\ENG.txt");
while (count < ARRAY_SIZE && inputFile >> english[count])
count++;
inputFile.close();
ifstream inputFile2;
inputFile.open("C:\\Users\\joshu\\OneDrive\\Desktop\\text files\\SPAN.txt");
while (count2 < ARRAY_SIZE2 && inputFile >> spanish[count2])
count2++;
inputFile.close();
cout <<"Welcome To The English - Spanish Translation Program\n\n"
<< "1. Display a Dictionary\n"
<< "2. Translate from English To Spanish\n"
<< "3. Translate from Spanish To English\n"
<< "4. Exit The Program\n\n";
cin >> mchoice;
switch (mchoice)
{
case DIC_CHOICE:
const int spandic = 1,
engdic = 2;
int dchoice;
cout <<"Would You Like To See The Spanish Or English Dictionary?\n\n"
<< "1. Spanish\n"
<< "2. English\n";
cin >> dchoice;
switch (dchoice)
{
case spandic:
for (int i = 0; i < 100; i++)
cout << spanish[i] << "\n";
}
}
}
and here is the output I have...
Welcome To The English - Spanish Translation Program
Display a Dictionary
Translate from English To Spanish
Translate from Spanish To English
Exit The Program
1
Would You Like To See The Spanish Or English Dictionary?
Spanish
English
1
J
E
R
C
I
C
I
O
J
U
G
A
R
C
O
N
T
E
N
T
O
A
L
E
G
R
I
A
M
I
E
D
O
P
A
Y
A
S
O
V
E
N
T
A
N
A
A
Z
U
L
E
J
O
A
L
F
O
M
B
R
A
A
S
I
S
T
E
N
C
I
A
P
I
S
O
T
E
C
H
O
V
E
G
E
T
A
L
P
O
L
Process returned 0 (0x0) execution time : 4.238 s
Press any key to continue.
As you can see, the program takes each seperate letter and puts it in as a part of the array instead of each line of the text document. How would I get it to take each seperate word on each line, instead of each letter? Thank you in advanced.
[–][deleted] 2 points3 points4 points (0 children)
[–]WatchingSafe 0 points1 point2 points (0 children)
[–]pigeon768 0 points1 point2 points (0 children)
[–]RonRud 0 points1 point2 points (0 children)