You can simply use the constructor instead ifstream file("test.txt"); //I would also store the filename into a variable
I would also remove line 10 and change line 11 to while(file >> fileContent) line 16 is also not needed since the destructor will call it, I would only call manually if you are going to check if it failed on close or something.
As for the problem you are having I see no problem with a character array though I would suggest using a std::string so something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <string>
#include <fstream>
int main()
{
std::string const filename = "test.txt";
std::ifstream in(filename); //if you don't have c++11 enabled you need filename.c_str()
std::string input = "";
while(in >> input)
{
std::cout << input << ' '; //how ever you want displayed you can also use getline to read instead of operaor >> if you want an entire line
}
return 0;
}