c++ debugger game

Yet another game! yay. It works like this, we take turns posting code snippets that have 1-3 bugs in them. Maybe more later. The object is to see who spots the bugs first. Ill start really, really simple.

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{

cout << "hello world"
system("PAUSE");
return EXIT_SUCCESS;
}
It would make more sense to post programs which has logical problems, not syntactical. These kind of syntactical problems are even detected by my IDE (not by compiling). Also if you thought system() was a bug, then we can post "bad habit" bugs also. So my rewrite of this program would be :
1
2
3
4
5
6
7
8
9
10
#include <limits>
#include <iostream>

using namespace std;

int main() {
    cout << "hello world";
    cin.ignore( numeric_limits<streamsize>::max(), '\n' );
    return 0;
}

I am not familiar with <limits>
I'd use cin.get() instead of cin.ignore(etc.)...
Actually if you don't use the extracted data from get() , then get() and ignore() are pretty much equivalent.
Ok =]
Topic archived. No new replies allowed.