Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

find string from reverse of a string in c++

Posted on 2003-03-04
3
Medium Priority
?
194 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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Progress

578 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