not declared in this scope

Hey i am really new and i bought a book on coding for c++ and every time i mannulay type in some sample code out of the book it always says random errors like 'system' was not declared in this scope.... what is a scope and how do i fix it because i run into that error a lot.

thanks

here is the code by the way its out of the book showing me the bool function

#include <cstdio>
#include <iostream>
#include <iostream>

using namespace std;

int main(int nNumbersofArgs, char* pszArgs[])
{
cout.setf(cout.boolalpha);

int nArg1;
cout << "inout value 1: ";
cin >>nArg1;

int nArg2;
cout << "input value 2: ";
cin >> nArg2;

bool b;
b = nArg1 == nArg2;

cout << "the statement, " << nArg1
<< " equals " << nArg2
<< "is" << b
<< endl;
system("PAUSE");
return 0;
}
closed account (zb0S216C)
A few pointers:

1) <cstdio> is a C-converted-to-C++ header. It has no place in your program.
2) <iostream> was included twice. One of the two lines need to go.
3) For system() to work, your program requires the <cstdlib> header.

Wazzak
Last edited on
It also sounds like you need to find yourself a better book. It isn't one of those awful Malik or 21 Days ones, is it? (I am curious what book it actually is, though.)
ok so <csrdlib> things of that nature do what exactly. and the book is c++ for dummies. what book would you recommend for a beginner i like books that teach you have to build something massive but along the way it shows you what each part does. i dont know if you understand a word im saying but yeah if you could recommend a book for a beginner that be really cool. btw i know java script quite well.

thanks for the feedback
The C++ for Dummies book makes some errors (sometimes egregious errors), and it is rather dated now, but is not that bad as a starter book. I don't personally recommend it though.

Grey Wolf makes some very good recommendations here
http://www.cplusplus.com/articles/GLzyhbRD/#CPP-Beg
thanks for the lead yeah im reading alot of reviews on the books he recommends and they are amazing ill probably invest in one of those

thanks again
Topic archived. No new replies allowed.