atoi() //把字符串转换成整型数

如果该输入无法转换为该类型的值,则atoi的返回值为 0。
atoi(“abcd”);//括号内不是可以转化的类型,这种情况会返回0

#include <iostream>
#include<cstdlib>
using namespace std;
int main()
{
	int n;
	cin >> n;
	char a[100];
	char b[100];
	_itoa_s(n, a, 2);
	n =atoi(a);
	cout << n<<endl;
	int m;
	cin >> m;
	_itoa_s(m, b, 16);
	cout << b<<endl;
	m = atoi(b);
	cout << m<<endl;
	system("pause");
	return 0;
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43838785/article/details/89502269
今日推荐