I have this function to copy a file word for word to another file.
void copy()
{
ifstream file;
file.open("file");
ofstream tabel;
tabel.open("copy");
string word;
char x;
x = file.get();
while (x != ' ')
{
word += x;
x = file.get();
}
tabel << word;
word.clear();
while (!file.eof())
{
x = file.get();
while (x != ' ')
{
word += x;
x = file.get();
}
tabel << word << " ";
word.clear();
}
}
But my VS gets stuck when I Run this code. Why I cant write to "tabel" file?
I think the problem is here
while (!file.eof())
{
x = file.get();
while (x != ' ')
{
word += x;
x = file.get();
}
tabel << word << " ";
word.clear();
}