当前位置:网站首页>Million data document access of course design

Million data document access of course design

2022-07-07 14:14:00 sinat_ thirty-six million seven hundred and eighty-nine thousan

Other types are converted to string type :

        string to_string (int val);
        string to_string (long val);
        string to_string (long long val);
        string to_string (unsigned val);
        string to_string (unsigned long val);
        string to_string (unsigned long long val);
        string to_string (float val);
        string to_string (double val);

        string to_string (long double val);


c_str() yes Borland Packaged String A function in class , It returns the first character address of the current string . When you need to open a file with a file name entered by the user , It can be written like this :ifstream in(st.c_str())


Examples :

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
string  a="outputdsaftttt.txt";
    ofstream output( a.c_str(), ios::out);
    if( ! output )
    {
        cerr << "Open output file error!" << endl;
        exit( -1 );
    }
    output.close();
    return 0;
}

原网站

版权声明
本文为[sinat_ thirty-six million seven hundred and eighty-nine thousan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071212223753.html