Hello Everybody,
I'm having a tiny issue that is like a GIANT for meThis program use a text file named yes.txt with these lines and NO blank line at the beginning or end of file:
sing
Sing
SANG!!!
yes
no
nope YES nope YES
I want to eliminate this external file and do the same thing with the same text being inside the program in a string array. I thought it should be simple, I included a array "string zfile[6]" to replace the external file but I don't know how to make it sing again. I google but it seems that everyone want to do the opposite. I been trying for hours. What do i need to change to make this happen. Thanks in advance
Code:#include <iostream> #include <fstream> #include <string> #include <vector> using namespace std; string zfile[6]={"sing", "Sing", "SANG!!!", "yes", "no", "nope YES nope YES",}; //string zfile[6]; int main() { ifstream xfile("yes.txt"); if ( !xfile ) { cerr << "File does not exist.\n\n"; system("pause"); exit( 1 ); } vector<string> lines; string line; while (getline(xfile, line)) { lines.push_back(line); cout << "results: " << line << endl; } xfile.close(); system("pause"); }



LinkBack URL
About LinkBacks
This program use a text file named yes.txt with these lines and NO blank line at the beginning or end of file:


