#include <iostream>
#include <cstdlib>
int main() {
const char* str = "1234567890";
long long num = atoll(str);
std::cout << "Converted number: " << num << std::endl;
return 0;
}
#include <iostream>
#include <cstdlib>
int main() {
const char* str = "-9876543210";
long long num = atoll(str);
std::cout << "Converted number: " << num << std::endl;
return 0;
}
#include <iostream>
#include <cstdlib>
int main() {
const char* str = "abcd1234";
char* endptr;
long long num = atoll(str);
if (*endptr != '\0') {
std::cerr << "Error converting string to long long" << std::endl;
} else {
std::cout << "Converted number: " << num << std::endl;
}
return 0;
}
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: 如何在C++中自定义Spline函数