Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string.h

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am trying to make a program that will search the entire file called stu.txt for the words "the" and "The." Also, if there is a word such as "othello" or "Theodore" it should recognize that the words it is searching for is located imn another word. Then it should record what position the "the" or "The" is inside another word....so if the program came accros "Theodore" it would record 0 because thats where "The" starts.
 
ifstream in("input.txt");

char buffer[256];
char* ptr;
while(!in.eof && in.peek() != EOF)
{
in>>buffer;
ptr = strstr(buffer,"the");
if(ptr)
// location = ptr - buffer (looks weird but will get value)

ptr = strstr(buffer,"The");
// same as above


}

Matt
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top