Check out example codes for "c++ file to string". It will help you in understanding the concepts better.

Code Example 1

string filetostring(){
	ifstream file("file", ios::binary);
    string fileStr;

    istreambuf_iterator<char> inputIt(file), emptyInputIt;
    back_insert_iterator<string> stringInsert(fileStr);

    copy(inputIt, emptyInputIt, stringInsert);

    return fileStr;
}

Learn ReactJs, React Native from akashmittal.com