Yep, Bruce Eckel allows good sites to mirror his book, for those that wish to download it.

My question is aimed towards would be novice C++ programmers, whom have read the first few chapters of Thinking in C++.

To the point:

At the end of Chapter 2, of the first book, there are exercises you can do.

One of these exercises has stumped me. Specifically:

# Display a file a line at a time, waiting for the user to press the “Enter” key after each line.

I would like to know how new readers/programmers(c++) managed to figure out how to do that one?

My first idea was to just use system("pause");, but then I realized that it wouldn't be practical, since linux doesn't actually have a pause program.

The reason this stumps me is that, in Chapter 2, it doesn't show you how to do this. I was able to do all of the exercises except this one because of that.

Basically, I wanted to ask someone how they did it, as a new programmer reading this book.

--

My "programming" skills are fairly limited. I started off with mIRC, and afterwords did a little perl (which I sometimes wish Khaled would add support for perl scripts!# but that's another discussion altogether.)

I had given "C++ for Dummies" a shot a while back, but most of the examples they gave me didn't work, so I ended up giving up on it before I got into the language. Just the other day I had decided to pick C++ back up again, after someone recommended "Thinking in C++"

Anyway, as an example of the code:

Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main () {
    string line;
    ifstream in("C:/testing.txt");
    while (getline(in, line)) {
        cout << line << endl;
        //  Need a way other than system("pause");
        //  Must wait for "enter" to be pressed.
        // Editted code:
        cin.get();
    }
}


So yeah, I'm pretty new to this. Go me..

Edit:


Okay, I just found out that Bruce Eckel has an Annotated soultions Guide. The solutions for Chapter 2 are free, but you have to pay $12 to buy the ebook if you want what is in the latter chapters.

With this said, I have the answer to my question.

cin.get();

Link: http://mindview.net/Books/TICPP/Solutions/SampleChapter

Last edited by Rand; 15/08/06 12:54 PM.