小编use*_*ser的帖子

std :: to_string vs stringstream

下面的代码显示2种溶液(std::to_string和std::stringstream),该转换的int m_currentSoundTime到std::string.是更快std::to_string还是std::stringstream更快?

// Compute current sound time in minute and convert to string
stringstream currentTime;
currentTime << m_currentSoundTime / 60;
m_currentSoundTimeInMinute =  currentTime.str();
Run Code Online (Sandbox Code Playgroud)

要么

m_currentSoundTimeInMinute = to_string( m_currentSoundTime / 60 );
Run Code Online (Sandbox Code Playgroud)

c++ tostring stringstream c++11

5
推荐指数
2
解决办法
7029
查看次数

如何逐行读取文件时跳过字符串

从包含名称和值对的文件中读取值时,我设法跳过了名称部分.但是有没有另一种方法可以跳过名称部分而不声明一个虚拟字符串来存储跳过的数据?

示例文本文件:http://i.stack.imgur.com/94l1w.png

void loadConfigFile()
{
    ifstream file(folder + "config.txt");

    while (!file.eof())
    {
        file >> skip;

        file >> screenMode;
        if (screenMode == "on")
            notFullScreen = 0;
        else if (screenMode == "off")
            notFullScreen = 1;

        file >> skip;
        file >> playerXPosMS;

        file >> skip;
        file >> playerYPosMS;

        file >> skip;
        file >> playerGForce;
    }

    file.close();
}
Run Code Online (Sandbox Code Playgroud)

c++ file-io iostream

3
推荐指数
1
解决办法
9209
查看次数

在void函数中返回的目的是什么

在函数的最后一行放入还是不放回头有什么不同吗?

void InputClass::KeyDown(unsigned int input)
{
    // If a key is pressed then save that state in the key array
    m_keys[input] = true;
    return;
}
Run Code Online (Sandbox Code Playgroud)

c++

2
推荐指数
2
解决办法
523
查看次数

标签 统计

c++ ×3

c++11 ×1

file-io ×1

iostream ×1

stringstream ×1

tostring ×1