why this if statements fails??!?
Look at the following code which compares for an argument string in the command line:
Code:
if (argc <= 1 || argc >= 3)
DisplayHelp();
// interpretar la linea de comandos
char* param = new char[strlen(argv[1])+1];
strcpy (param, argv[1]);
if (param == "-s")
{
cout << "SAVeonly" << endl;
}
exit(1);
I enter -s to test in the command line and the if statement fails!!!
Where I can't compare param == "-s"?? There is anything related to the way i create char*param=new... etc... ???
Thank you!
ive found another similar solution...
I found in DEVX.com the following code snippet that will do the trick.
Code:
std::transform(pm.begin(), pm.end(), pm.begin(), (int(*)(int)) toupper);
I think its more compact...
Thank you Paul for your help!
(also, i dont know if this is good technique, I ve made the following macro to easier use)
Code:
#define STRTOUPPER(x) (std::transform((x).begin(), (x).end(),\
(x).begin(), (int(*)(int)) toupper));
Is this good technique? or bad programming practice? Many sites tell that C Macros are a bad technique in C++.