C++ system commands

I took up programming last nigh for the first time in about six months, and I had a problem with the following source code (yeah, I know I'm a noob):

 

#include <iostream>


using namespace std;

int main (){
system("color a");
cout << "This program adds a variable a to a variable b." << endl;
float a;
cout << "Input variable a: " << endl;
cin >> a;
cout << "Input variable b: " << endl;
float b;
cin >> b;
float c;
c = a+b;
cout << "your answer is: " << c << endl;
cin.get();
return 0;
}

 

the error:

line 7: 'system' was not declared in this scope

now, I've made programs like this before (more complex than this, but it's been six months) and I know that the color is unnessasary, but the problem is that no system commands work. Can anyone help me?

im guessing here, but maybe you need to include the system header?

sorry that the source code didn't copy and paste right

Also, I don't understand what you mean by system header. I'm sorry to be a pain in the a**, bus I have about a month's worth of coding knowledge under my belt, period.

http://www.cplusplus.com/forum/beginner/5830/

To use system() you need to #include <cstdlib> ref-> http://www.cplusplus.com/reference/cstdlib/system/


What OS are you compiling and running in?


You should probably use something like pastebin to paste code to the forum since there aren't any code tags to help wrap and keep formatting. Looks like this, even has syntax highlighting: http://pastebin.com/0tS59HJD


That all being said, why are you using system() ??

Cause you probably shouldn't. Especially when relearning. It's pretty much crap.