Karls
asked on
analysing strings
I have a string[240] and I want to search this string for several different words. The words could be in any part of the string.
is there a function that will search the string for the specified word or do i need to create one?
is there a function that will search the string for the specified word or do i need to create one?
#include <string.h>
char *strstr (const char *s1, const char *s2);
char *strstr (const char *s1, const char *s2);
hi,
u can use find member from basic strings....
string str("ur string over here");
if(str.find("ur world")>=0)
found the word in string
u can use the no of find just go through the documentation of find() overloaded versions...
i think this will help u ......
rgds,
himmya.
u can use find member from basic strings....
string str("ur string over here");
if(str.find("ur world")>=0)
found the word in string
u can use the no of find just go through the documentation of find() overloaded versions...
i think this will help u ......
rgds,
himmya.
if you want the C-Style search then use the function above to locate the strings....within a for loop....or use a C++ style STL string class and use its member function find...again within a for loop
Hi (himmya ), welcome to EE.
All of the experts here, for the most part have learn from other experts as to the proper etiquette for posting answer.
An answer should not be posted as an answer, if other experts have previously posted possible answers as comments, and/or have already made contributions to the question.
There are many experts who never post answers as answer. Instead, they post their answers as comments.
If you read the following link, you'll see why this is the preferred method for many of our valued experts, including myself.
https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp
Hi (Karls):
Feel free to click the [Reject Answer] button near (Answer-poster's) response, even if it seems like a good answer.
Doing so will increase your chance of obtaining additional input from other experts. Later, you can click the [Select Comment as Answer] button on any response.
All of the experts here, for the most part have learn from other experts as to the proper etiquette for posting answer.
An answer should not be posted as an answer, if other experts have previously posted possible answers as comments, and/or have already made contributions to the question.
There are many experts who never post answers as answer. Instead, they post their answers as comments.
If you read the following link, you'll see why this is the preferred method for many of our valued experts, including myself.
https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp
Hi (Karls):
Feel free to click the [Reject Answer] button near (Answer-poster's) response, even if it seems like a good answer.
Doing so will increase your chance of obtaining additional input from other experts. Later, you can click the [Select Comment as Answer] button on any response.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thats what I was looking for.
You don't actually need to do it in a for loop though. will do the entire line.
You don't actually need to do it in a for loop though. will do the entire line.
strstr - Find a substring
char *strstr( const char *string, const char *strCharSet );
returns a pointer to the first occurrence of strCharSet in string, or NULL if strCharSet does not appear in string.