I currently have two .txt files, one files which contains characters, i wish to create a file stream and grab the characters from that file and put them into an array of characters.
I then also have a text file with 6 strings on a different line, i need to add these into an array of strings here is my code so far, i am having a slight error when i am trying to put the value of "words" my string file for the string array into each position in an array.
//Gets the characters from the textfile and creates an array of characters.
char ch;
fstream fin("text1.txt", fstream::in);
while (fin >> noskipws >> ch) {
char letters[5];
cout << ch;
for (int i = 0; i < 14; ++i)
{
ch >> letters[i];
}
}
fin.close();
//Get the words from the file and add into an array of strings
string words;
fstream fin2("search1.txt", fstream::in);
while (getline(fin2, words)) {
string wordsArray[6];
cout << words;
for (int i = 0; i < 6; ++i)
{
words >> wordsArray[i];
}
}
fin2.close();