字符串转数字
#include<iostream>
#include<string>
#include <stdio.h>
using namespace std;
int main()
{
char str[]= "123456";
int a;
sscanf(str, "%d", &a); //换成%x等可以实现进制之间的转换
cout << a;
return 0;
}
数字转字符串
//字符串转数字
#include<iostream>
#include<string>
#include <stdio.h>
using namespace std;
int main()
{
char str[]= "123.456";
double a;
sscanf(str, "%lf", &a); //换成%X之类可以实现进制之间的转换
cout << a;
return 0;
}