Once again hi.
I tried to write a function getWord that gets a word from a file, but during the compilation i get some errors that i hardly undrestand:
May someone tell me what's wrong with this?Code:#include <fstream>
using std::ifstream;
#include <iostream>
#include <string>
using std::string;
string getWord(ifstream file);
int main(){
char c;
ifstream file;
string first;
file.open("document.txt");
getWord(file,first);
std::cout<<"first="<<first<<"\n";
return 0;
}
string getWord(ifstream file){
string s;
char c;
while(file.get(c)&&c!=' ')
s.push_back(c);
return s;}