hi everyone, how can i input the data tat is from input file stream...
this is the code tat i am doing now ... but have an error.. please let me know and correct for me if someone know the problem... thank you
Code:#include <iostream> #include <cstdlib> #include <fstream> using namespace std; int main() { //declare numRows, numColumns and string const int numRows = 6; const int numColumns = 3; string hands[numRows][numColumns]; //initialise the string and assign each to 'X' for(int row = 0; row < numRows; row++) { for(int col = 0; col <numColumns; col++) { hands[row][col] = 'x'; } } //input data from the input.txt and display the string ifstream myfile ("input.txt"); if(!myfile) { cout<<"Cannot open file."<<endl; return 1; } for(int row = 0; row < numRows; row++) { for(int col = 0; col <numColumns; col++) { myfile>>hands[row][col]; } cout<<endl; } myfile.close(); system("PAUSE"); return 0; }