【发布时间】:2015-04-20 01:08:30
【问题描述】:
我正在使用 OpenGL,我需要将 VertexShader.glsl 的内容放入 std::string
我已经查看了有关此的相关 StackOverflow 帖子,但我真的不知道如何将数据类型和内容匹配在一起以使其工作。
以Read file-contents into a string in C++为例
#include <fstream>
#include <string>
int main(int argc, char** argv)
{
std::ifstream ifs("myfile.txt");
std::string content( (std::istreambuf_iterator<char>(ifs) ),
(std::istreambuf_iterator<char>() ) );
return 0;
}
我不知道之后发生了什么
std:: 字符串内容
我以前每次使用 std::string 都是这样的
std::string name = "2bdkid";
【问题讨论】:
标签: c++ string file-io constructor