使用 istreambuf_iterator :
1 ifstream inputFile( "interestingData.txt" ); 2 string fileData( (ifstreambuf_iterator<char>(inputFile)), istreambuf_iterator<char>() );
使用 istreambuf_iterator :
1 ifstream inputFile( "interestingData.txt" ); 2 string fileData( (ifstreambuf_iterator<char>(inputFile)), istreambuf_iterator<char>() );