Jul
21
Read A Text File
ByThis will open a text file and read it line by line. As it is, it will just print each line to the screen, so very much like the unix ‘cat’ command, but could very well do anything on the line just read by replacing the cout statement.
#include <fstream> #include <iostream> #include <string> void main() { string s; ifstream infile; infile.open("aaa.txt"); while(infile >> s) { cout << s << endl; } }
Leave a Comment
You must be logged in to post a comment.