dimanche 19 avril 2015

Take file contents and put it into a string in C++

I'm using OpenGL and I need the contents of VertexShader.glsl to be put into a std::string


I've looked at the related StackOverflow posts about this but I don't really know how to match together data types and stuff to make it work.


Take for example this from 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;
}


I have no clue what's happening after



std:: string content



Every time I have used std::string before has been like



std::string name = "2bdkid";

Aucun commentaire:

Enregistrer un commentaire