Hi
I am trying to read a file and then print out information about that file using a function.
Here is the code i have so far:
Code:#include <iostream> #include <fstream> #include <string> using namespace std; ifstream in; void NoOfChars(); int main() { string file; cout << "Enter the file name you wish to open: " << endl; cin >> file; cout << "The file you wish to open is: " << file <<endl; in.open(file); if (in.fail()) { cout << "File failed to open" << endl; } // Then print out the information here cout<<"Number of Chars: "<< NoOfChars(in)<<endl; } void NoOfChars() { //Function code here return chars; }
My question is, do i have the right idea?
Thanks