0

I use Putty for coding, so my question, while general in scope, is asked from the perspective of that program.

How do you take a file from the command line and read it line for line into the main program so it can then be parceled out and manipulated in functions? I understand that you use the fstream class, but I'm not sure at the correct procedure for actually reading lines from the file

1
  • 3
    Putty is a terminal emulator, it has nothing to do with coding. Commented Oct 12, 2013 at 16:22

1 Answer 1

1

This is a simple sample:

ifstream in("file.txt");

if (!in.is_open())
{
    cout << "Error - cannot open the file." << endl;
    return 0;
}

string line;
while (getline(in, line))
{
    cout << line << endl;

    ...

}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.