c++ - Read hexa data from file -


i'm trying read hexa data(color value ex. 0xffffffff) txt file...

but don't know how read it....

i declared color value 'uint color' , want change value though txt file.

if use int data can use 'atoi' function, can use function uint?

you can use strtoul

strtoul returns long, can 1 of 2 things:

  1. just truncate data
  2. check if fits in unit

example usage:

char *endptr; unsigned long ul = strtoul(str, &endptr, 16); if (str == endptr)     // error, no data converted  // truncate unsigned int utrunc = (unsigned int)ul;     // or can first check if fits if (ul < uint_max)     unsigned int ufit = (unsigned int)ul;   

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -