Answers for "c++ string to digita"

C++
3

convert string to number c++

#include <iostream>
#include <sstream>
using namespace std;
int main()
{
	string str = "123456";
 	int n;
  	stringstream ( str ) >> n;
	cout << n; //Output:123456
	return 0;
}
Posted by: Guest on April-16-2021
0

string to decimal c++ strtol

char hex[] = "6A";                          // here is the hex string
int num = (int)strtol(hex, NULL, 16);       // number base 16
printf("%c\n", num);                        // print it as a char
printf("%d\n", num);                        // print it as decimal
printf("%X\n", num);                        // print it back as hex
Posted by: Guest on December-23-2021

Browse Popular Code Answers by Language