Return to Snippet

Revision: 56180
at March 14, 2012 21:24 by vdevos


Updated Code
/* 
   IN:  program ff aa
   OUT: Values: ff, aa
*/

int main (int argc, char *argv[]) {
 
  unsigned int values[2];
 
  values[0] = strtol(argv[1], NULL, 16);
  values[1] = strtol(argv[2], NULL, 16);
  
  printf("Values: %x, %x", values[0], values[1]);
}

Revision: 56179
at March 14, 2012 21:21 by vdevos


Initial Code
int main (int argc, char *argv[]) {
 
  unsigned int values[2];
 
  values[0] = strtol(argv[1], NULL, 16);
  values[1] = strtol(argv[2], NULL, 16);
  
  printf("Values: %x, %x", values[0], values[1]);
}

Initial URL

                                

Initial Description
This piece of code will read a hex argument such as: ff or ab from your command line and stores it as a integer

Initial Title
Read hexadecimal argument from command line

Initial Tags
c

Initial Language
C