As far i know, in C, I can't do a switch with strings, so i have a question: Which code is more correct? This, creating a new variable called metd and saving in it? or putting the code directly on the if's?
New variable
int metd=0;
if (strcmp( method, "GET")==0){
metd=1;
}
if (strcmp( method, "HEAD")==0){
metd=2;
}
switch (metd)
{
case 1:
//actions
break;
case 2:
//actions
break;
default:
//actions
break;
}
If's party
if (strcmp( method, "GET")==0){
//actions
}
if (strcmp( method, "HEAD")==0){
//actions
}
Aucun commentaire:
Enregistrer un commentaire