I'm currently studying basic c++, and I've encountered a problem that I can't deal with. In the below code you can see my program. What's bad about it, is that from the cout << word; I can see the content of my text file, but the cout << astring doesn't show me anything. Could anyone please point me out the mistake?
P.s. It has to be done with functions.
void read(string word); int main() { string astring; read(astring); cout << astring; return 0; } void read(string word) { ifstream duom ("info.txt"); if (duom.is_open()) { while(!duom.eof()) { getline(duom, word); cout << word; } } else cout << "File couldn't be opened"; }