I believe you are looking for some specific text within the host file ? This is the classic problem where grep, egrep, awk, sed and Perl etc shines. Depending on how complicated is your specific text, normal reading and then searching using C++ will suffice but in most cases I prefer Perl regular expression built-in syntax :P