I have a project and am hung up at the moment. I am supposed to read from a file containing all of the function calls that I need to make. For example:

Insert(33)

would call the Insert function with an int paramater 33.

How can I read this in from a file? Is there a call similar to get(char) that works for a string?

Recommended Answers

All 3 Replies

getline() will read the entire line

std::string line;
std::ifstream in("filename.txt");
while( getline(in, line) )
{
    cout << line << "\n";
}

getline() is a good option over getchar()

In the same way it can also be done using do-while....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.