7 int main(int argc, char ** argv)
11 cerr << "Usage : " << argv[0]
12 << "Calc.exe file.in" << endl << endl
13 << "-> lit le fichier file.in et exécute les commandes" << endl;
16 ifstream in(argv[1], ios::in);
22 string buf_ligne; // pour lire une ligne
23 while ( getline(in, buf_ligne) ) // parse le fichier d'entree
25 if( (buf_ligne.find("MUL")) != string::npos)
27 istringstream buf(buf_ligne.c_str());
28 buf >> name >> i1 >> i2;
29 cout << "MUL(" << i1 << "," << i2 << ")=" << myCalc.mul(i1,i2) << endl;
31 else if (buf_ligne.find("ADD") != string::npos)
33 istringstream buf(buf_ligne.c_str());
34 buf >> name >> i1 >> i2;
35 cout << "ADD(" << i1 << "," << i2 << ")=" << myCalc.add(i1,i2) << endl;
37 else if (buf_ligne.find("FACT") != string::npos)
39 istringstream buf(buf_ligne.c_str());
41 cout << "FACT(" << i1 << ")=" << myCalc.fact(i1) << endl;