read from file only from one specific line to another C++ -
Is there any way to read the data in the second line from the file?
For example: In these lines: Line 1: Empty row Line Line line: blank line Line 3: Robert W. Line 4: Take the frank Line 5: Sylvia ops Line 6: Blank line Line 7: Blank line Line 8: Andy SF And I only have to read from line 3 to line 6 Then the output will be: Robert V Frank le Sylvia op and my file has 300 lines thanks class = "post-text" itemprop = "text"> This should do the trick: < Code> #include & lt; Iostream & gt; # Include & lt; Fstream & gt; #include & lt; String & gt; using namespace std; Int main () {string line; Infinite Infile; Infile.open ("putyourinputfilehere.txt"); While (Getline (Infail, Line)) {if (line! = "") {Cout & lt; & Lt; Line & lt; & Lt; Endl; }} Infile.close (); Return 0; }
Comments
Post a Comment