Reading in from a File

How do I modify a program to read in a specific part of the file? For example, "zip: 00000", from a very large file. The code below reads in the entire file and prints it. Thank You.

1
2
3
4
if (inF.is_open()) {
		while (getline(inF,z)) { 
               		cout << z << '\n';
              	}      
How do I modify a program to read in a specific part of the file?

You can't, you have to either read the file a piece at a time until you find what you are looking for, or read the entire file into memory and search that instead. Since you're already using "getline()" I'd recommend "strstr()" from the cstring\string.h header file: http://www.cplusplus.com/reference/cstring/strstr/

Topic archived. No new replies allowed.