-6

I'm new to C++ and I keep getting a message saying something was not declared in the scope. How do I declare stuff in the scope?

This is a bit of code I wrote, when compiling I get the message that system and return0 where not declared in the scope, how do you fix the code? How do I declare stuff in the scope?

#include <iostream>

using namespace std;

int main()

{
    cout<<"hello";
    system("PAUSE";

    return0;
}

2 Answers2

2

Firstly, you must add the include for system:

#include <cstdlib>  

Secondly you need to add a closing parentheses on the system call and then put a space between return and 0. E.g.:

system("PAUSE");
return 0;

As has been suggested in the comments, the use of system is strongly discouraged. Reasons are listed in this answer

Community
  • 1
  • 1
Steve
  • 7,171
  • 2
  • 30
  • 52
0

system() is declared in <cstdlib>, and you're missing a ) at the end of the function call.

return0 should be return 0

Mike Seymour
  • 249,747
  • 28
  • 448
  • 644