Over a million developers have joined DZone.

[C] - Read Hex Argument From Console Into Integer

DZone's Guide to

[C] - Read Hex Argument From Console Into Integer

Free Resource
// This code Reads a hexadecimal argument from the commandline and puts it into a integer

 //  INPUT:   ./prog ff aa
 //  OUTPUT:  hex_values: ff and aa

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


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}