I am trying to allow the user to input the name of a .txt file so I can add the integers from it into an array.
//filereading-----------------ifstreaminfile;stringfilename;cout<<"Enter File name (no spaces): ";cin>>filename;infile.open(filename);//<---------WHERETHEERRORSHOWSintcount=0;while(!infile.eof()){infile>>inputA[count];count++;}infile.close();//------------------------------
It always throws this error :[Error] no matching function for call to 'std::basic_ifstream<char>::open(std::string&)'</char>
Last edit: thormander 2022-05-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ifstreaminfile;stringfilename;cout<<"Enter File name (no spaces): ";cin>>filename;infile.open(filename.c_str());intcount=0;while(!infile.eof()){infile>>inputA[count];count++;}infile.close();
Check this code, If this is working for you or not?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to allow the user to input the name of a .txt file so I can add the integers from it into an array.
It always throws this error :[Error] no matching function for call to 'std::basic_ifstream<char>::open(std::string&)'</char>
Last edit: thormander 2022-05-11
Check this code, If this is working for you or not?