Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.
Do more with
string str = "(HEADER MESSAGE-ID <8d8vhsk5qqpfl7lyetqsbdsb.1264020499132@email.android.com>)";
const char* p = str.c_str();
char * t = const_cast<char*>(p);
string result;
char * ptr;
t = strtok_r(t, "<", &ptr);
t = strtok_r(NULL, ">", &ptr);
result = t;
cout << result << endl;
string str = "(HEADER MESSAGE-ID <8d8vhsk5qqpfl7lyetqsbdsb.1264020499132@email.android.com>)";
char* p = (char *)malloc( str.size() + 1 );
string result;
char * ptr;
strncpy( p, str.c_str(), str.size() + 1 );
p = strtok_r(p, "<", &ptr);
result = strtok_r(NULL, ">", &ptr);
free(p);
cout << result << endl;
string str = "(HEADER MESSAGE-ID <8d8vhsk5qqpfl7lyetqsbdsb.1264020499132@email.android.com>)";
string result;
int bpos, epos;
if( ( (bpos = str.find("<") )!= string::npos ) &&
( (epos = str.find(">") )!= string::npos ) &&
(bpos < epos) ) {
result = str.substr( bpos+1, epos - bpos -1 );
}
else {
cout << "<> pair not found" << endl;
}
cout << "result = " << result << endl;
Premium Content
You need an Expert Office subscription to comment.Start Free Trial