I have an array of characters. I am trying to find "houston". The only way I can think of to do this is to use a for loop and check each individual character. Is there an easier way to do this?

char string[] = "Fishing tourism miami atlanta dallas houston";

Recommended Answers

All 4 Replies

look up strstr() function. Another way is to call strncmp()

This did what I want.

char *pch;
char string[] = "Fishing tourism miami atlanta dallas houston";
pch = strstr (string,"houston");
if(pch != NULL && start_flag != 1)
{
    //Do Work
}

great :) so now your problem is solved??

Yes :). Marking as solved ;).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.