How to read from a file when user is asked to enter the file name
for example, the program will prompt
enter filename you wish to see,
and user enter file name and content of that file will show..i know i have to use ifstream but how to link with userinput filename and the file.
help..and thank you. Sorry im just a beginner
If you've learned c-strings only, it should be clear. You can read a filename to a char array and what ifstream::open wants from you is a char array as well, so just pass what you have.
If you use std::strings, it's not so clear. First read the filename, then use std::string::c_str() method to convert std::string to char* and pass what you get to fstream::open.
If it didn't get any more clear, post how you read ac string and how you open a file (unrelated operations). Then it will be more clear what your problem is.
how to make the program reads a list of students marks from an input file,the name of the file from the user.
(the list of students marks should be created by me)
each line in the input file contains a student number followed by marks in test (out of 10) separated by a tab
but I get an error :
error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'int [5]' (or there is no acceptable conversion)