c++ - System not declared in scope? -
i know simple code, how fix "system not declared in scope" problem?
#include<iostream> using namespace std; int main(void) { system ( "title calculator" ); system ( "color 2" ); char cchar; double dfirstnumber; double dsecondnumber; char cdoagain; { system("cls"); cout << "please enter first number use."<< endl; cin >> dfirstnumber; cout<< "please enter operation perform." << " (+,-,*,or /)" << endl; cin >> cchar; cout<< "please enter second number use." << endl; cin >> dsecondnumber; switch (cchar) { case '+': cout << "the answer is: " << dfirstnumber << "+" << dsecondnumber << "=" << (dfirstnumber + dsecondnumber) << endl; break; case '-': cout << "the answer is: " << dfirstnumber << "-" << dsecondnumber << "=" << (dfirstnumber - dsecondnumber) << endl; break; case '*': cout << "the answer is: " << dfirstnumber << "*" << dsecondnumber << "=" << (dfirstnumber * dsecondnumber) << endl; break; case 'x': cout << "the answer is: " << dfirstnumber << "x" << dsecondnumber << "=" << (dfirstnumber * dsecondnumber) << endl; break; case 'x': cout << "the answer is: " << dfirstnumber << "x" << dsecondnumber << "=" << (dfirstnumber * dsecondnumber) << endl; break; case '/': if(dsecondnumber == 0){ cout<< "that invalid operation." << endl;} else{ cout << "the answer is: " << dfirstnumber << "/" << dsecondnumber << "=" << (dfirstnumber / dsecondnumber) << endl; } break; default: cout << "that invalid operation." << endl; break; } cout << "would start again? (y/n)" << endl; cin >> cdoagain; }while (cdoagain == 'y' or cdoagain == 'y'); system("pause"); return 0; }
heres end message:
c:\documents , settings\nilo\my documents\work\testing\main.cpp||in function 'int main()':| c:\documents , settings\nilo\my documents\work\testing\main.cpp|8|error: 'system' not declared in scope||
|=== build finished: 1 errors, 0 warnings ===|
you need add:
#include <cstdlib>
in order compiler see prototype system()
.
Comments
Post a Comment