⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringconvert.cpp

📁 C++ sample code, for the book: C++ black book, including templates, exceptional handling.
💻 CPP
字号:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    char new_text[8];
    int new_integer, integer = 255;
    float new_float;
    string new_string, string_object("3.14159");

    itoa(integer, new_text, 10); 
    cout << "Converting the integer to a character string yields: " << new_text << endl;

    new_string = new_text; 
    cout << "Converting the character string to a string object yields: " << new_string << endl;

    new_integer = atoi(new_text);
    cout << "Converting the text back to an integer yields: " << new_integer << endl;

    new_float = atof(string_object.c_str());
    cout << "Converting the string object into a float yields: " << new_float << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -