ok, adesso mi da questo errore il g++:
codice:
linus-gates@linus-gates-desktop:~/cpp_files$ g++ -Wall -o math math.cpp
math.cpp: In function ‘int main(int, char**)’:
math.cpp:17: warning: unused variable ‘argomento1’
math.cpp:21: warning: unused variable ‘argomento1’
math.cpp:22: warning: unused variable ‘argomento2’
math.cpp:32: error: ‘argomento1’ was not declared in this scope
math.cpp:32: error: ‘argomento2’ was not declared in this scope
math.cpp:36: error: ‘argomento1’ was not declared in this scope
math.cpp:36: error: ‘argomento2’ was not declared in this scope
math.cpp:40: error: ‘argomento1’ was not declared in this scope
math.cpp:40: error: ‘argomento2’ was not declared in this scope
math.cpp:44: error: ‘argomento1’ was not declared in this scope
math.cpp:44: error: ‘argomento2’ was not declared in this scope
math.cpp:48: error: ‘argomento1’ was not declared in this scope
math.cpp:52: error: ‘argomento1’ was not declared in this scope
linus-gates@linus-gates-desktop:~/cpp_files$
ecco il codice, nn sembra avere nnt di strano...
codice:
/*math Main Source*/
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<math.h>
#include<string.h>
using std::cout;
using std::endl;
int main(int argc, char* argv[])
{
if (argc == 3)
{
float argomento1 = atof(argv[2]);
}
else if (argc == 4)
{
float argomento1 = atof(argv[2]);
float argomento2 = atof(argv[3]);
}
else
{
cout << "Usage: math [-p] [-m] [-t] [-d] [-q] [-v] argomento1 [argomento2]" << endl;
return 0;
}
if (strcmp(argv[1],"-p") == 0)
{
cout << argomento1 + argomento2 << endl;
}
else if (strcmp(argv[1],"-m") == 0)
{
cout << argomento1 - argomento2 << endl;
}
else if (strcmp(argv[1],"-t") == 0)
{
cout << argomento1 * argomento2 << endl;
}
else if (strcmp(argv[1],"-d") == 0)
{
cout << argomento1 / argomento2 << endl;
}
else if (strcmp(argv[1],"-q") == 0)
{
cout << argomento1 * argomento1 << endl;
}
else if (strcmp(argv[1],"-v") == 0)
{
cout << sqrt(argomento1) << endl;
}
else
{
cout << "Usage: math [-p] [-m] [-t] [-d] [-q] [-v] argomento1 [argomento2]" << endl;
}
return 0;
}
VVoVe: