c_cpp 在C ++中将str转换为int

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 在C ++中将str转换为int相关的知识,希望对你有一定的参考价值。

#include <iostream>
#include <string>
#include "Container.h"

//generic adding function
int concat(int x, int y){
	return x + y;
}

int main() {
	std::string result;
	std::cout << "Give a number" << std::endl;
	std::cin >> result;
	int value = atoi(result.c_str());
	Container a(value);
	std::cout << "You printed" << a.getint() << std::endl;
}

以上是关于c_cpp 在C ++中将str转换为int的主要内容,如果未能解决你的问题,请参考以下文章