LoginSignup
7
8

More than 5 years have passed since last update.

16進数文字列 -> long

Posted at

[todanano@localhost tmp]$ vi a.cpp
[todanano@localhost tmp]$ cat a.cpp


#include <stdio.h>
#include <stdlib.h>
#include <string>

int main( int argc, char **argv ) {

        std::string str = "FF";
        long num = strtol( str.c_str(), NULL, 16 );
        printf( "%ld\n", num );

        return( 0 );

}

[todanano@localhost tmp]$
[todanano@localhost tmp]$ g++ ./a.cpp
[todanano@localhost tmp]$ ./a.out
255
[todanano@localhost tmp]$
[todanano@localhost tmp]$

息抜きにちょろっと書いただけです。はい。

7
8
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8