[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppIfstream
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppIfstream
(C++) ifstream
A stream to read from a file.How do I read from file?
int main() { { //Write ofstream myFile("test.txt"); myFile << "More then one word"; myFile.close(); } { //Read ifstream myFile("test.txt"); std::string myString; std::getline(myFile,myString,'\n'); myFile.close(); std::cout << "I have read: " << myString << std::endl; } }
- include <fstream>
- include <iostream>
- include <string>
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
