Read Hexidecimal
-
Are there any standard functions, either in the c libary or in windows, that can be used to read a hexidecimal number from a string similar to atoi?
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life! -
Are there any standard functions, either in the c libary or in windows, that can be used to read a hexidecimal number from a string similar to atoi?
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!sscanf(), if you have a formatted string. For example:
#include <iostream>
#include <cstdio>using namespace std;
int main()
{
string str = "0x1F";
int hex = 0;
sscanf(str.c_str(), "%X", &hex);
cout << "Hex value: " << hex << endl;
return 0;
}Jon Sagara Working with a database is iterative, like sex, but painful instead of pleasurable. -- Marc Clifton[^]
-
Are there any standard functions, either in the c libary or in windows, that can be used to read a hexidecimal number from a string similar to atoi?
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life! -
sscanf(), if you have a formatted string. For example:
#include <iostream>
#include <cstdio>using namespace std;
int main()
{
string str = "0x1F";
int hex = 0;
sscanf(str.c_str(), "%X", &hex);
cout << "Hex value: " << hex << endl;
return 0;
}Jon Sagara Working with a database is iterative, like sex, but painful instead of pleasurable. -- Marc Clifton[^]
I saw this before, but for some reason it did not seem that it worked that way to me. Thanks
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life! -
strtol() or strtoul()
CPUA 0x5041 Sonork 100.11743 Chicken Little "So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies Within you lies the power for good - Use it!
Thanks, this is exactly what I was looking for.
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!