dimanche 29 mars 2015

Less tedious way to call values from the command line?



I currently have:



int main(int argc, char* argv[]){
char* array = argv[1];
char* test = argv[2];
char*p;
char*q;
long check;
long checker;

check = strtol(array, &p, 3);
checker = strtol(test, &q, 3);
printf("Check: %ld\n", check);
}


What would be faster/ more efficient way of calling the values from the command line without having to create a new variable (p,q,check,checker) every time a new value is called? ie. ./program 1 2 3


Also, why do values such as -9 return 0?




Aucun commentaire:

Enregistrer un commentaire