Ok, I am trying to write a bit of code that takes data from a file and uses it directly in the code. Here is a piece of code where only one line can be stored at a time and it is as a string. I want all the lines to be stored and as an integer. Can anyone help?
ifstream myfile ("example.txt");
if (myfile.is_open())
{
int value;
while (myfile >> value)
{
cout << value << endl;
}
}
else cout << "Unable to open file";