Hrmm... is there anyway to print more than just the first word of a text file using ifstream?
// Kavity
Printable View
Hrmm... is there anyway to print more than just the first word of a text file using ifstream?
// Kavity
use getline()
Would you be able to give me an example? :\
// Kavity
Code:#include <fstream>
#include <iostream>
#include <string>
// ...
std::ifstream fin("filename.txt", std::ios::in);
std::string buffer;
while (std::getline(fin, buffer))
std::cout << buffer << endl;