字符串转化为数字 不用sscanf

#include <iostream>
#include <string.h>
using namespace std;

int main() {
	int tmp;
	int num = 0;
	char s[] = "123";

	for (int i = 0; i < strlen(s); i++) {
		tmp = s[i] - '0';
		num = num * 10 + tmp;
	}

	cout << num;
}
原文地址:https://www.cnblogs.com/helloweworld/p/2953740.html