?
Solved

find string from reverse of a string in c++

Posted on 2003-03-04
3
Medium Priority
?
191 Views
Last Modified: 2010-04-17
how to find a string from a string from reverse side in c/c++ ?.
0
Comment
Question by:ujjaltitu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Expert Comment

by:ZalexZ
ID: 8070862
if you have the windows String class:

String xyz = "aloahejaaloahhejo";
int pos = xyz.lastIndexOf("aloah");

else

char xyz[] =  "aloahejaaloahhejo";
char find[] = "aloah"
int pos = -1;
for(int m=strlen(xyz)-strlen(find); m>0; m--)
{
    if(!memcmp(&find,&xyz,4))
    {

}
0
 

Accepted Solution

by:
ZalexZ earned 200 total points
ID: 8070941
Sorry submitted before finish;-)

Second possibility:

char xyz[] =  "aloahejaaloahhejo";
char find[] = "aloah";
int pos = -1;
for(int m=strlen(xyz)-strlen(find); m>=0; m--)
{
   if(!memcmp(find,xyz+m,strlen(find)))
   {
      pos=m;
   }
}

Tried it, and worked!

Regards
AZ
0
 

Expert Comment

by:CleanupPing
ID: 9447359
ujjaltitu:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Six Sigma Control Plans
Progress
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question