PDA

View Full Version : Simple question: Easiest way to search through a character arracy


willz99ta
03-25-2005, 05:40 PM
Thanks for reading my post and for any help you give me.

Im new at programming C and Im trying to find the letters 'ISA' in a 100 length character array. What is the easiest way to do this?

Thanks
Willz99ta

Dr. Evil
03-25-2005, 06:19 PM
You can use the function strstr() or strcasestr(), or you can do the search yourself. If the latter, essentially what you want to do is search through the string and if you come accross the first letter of the string you're searching for, call strncmp()/strnicmp() to see if the rest of the string shows up.