C++ 编程总结 一

时间:2021-05-21 09:26:47   收藏:0   阅读:34

C++ 编程总结

整形和string的相互装换

常见的用法和范围界定见代码

#include<bits/stdc++.h>
#include <climits>

using namespace std;

int main() {
    //string 2 Integer && Integer 2 string
    //int stoi (const string&  str, size_t* idx = 0, int base = 10);
    //Other functions are similar
    cout << stoi(to_string(INT_MAX), 0, 10) << endl;
    cout << stoi(to_string(INT_MIN)) << endl;
    cout << stol(to_string(LONG_MAX)) << endl;
    cout << stol(to_string(LONG_MIN)) << endl;
    cout << stoul(to_string(ULONG_MAX)) << endl;
    cout << stof(to_string(FLT_MAX)) << endl;
    cout << stod(to_string(DBL_MAX)) << endl;
    // ostringstream stream;
    // stream << INT_MAX;
    // cout << stream.str() << endl;
    return 0;
}

do {...} while(0)

一般见于#define 语句块中,为了不反直觉

原文:https://www.cnblogs.com/jamgun/p/14792076.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!