#include <iostream>
#include<string>
using namespace std;
class substr
{
public:
void getsubstr(char* b, char* db)
{
char* stpos = strstr(db,"gi|");
int pos = db-stpos;
char* end = strstr(db,"|ref");
int endpos = abs(db-end);
b= new char[endpos-pos+2];
int i=pos+3;
for(;i<endpos;i++)
{
*b++=*(db+i);
}
*(b+i)='\0';
}
};
int main()
{
substr* s;
char* b;
char* db= "gi|71772593|ref|NM_001032.3|";
s->getsubstr(b,db);
cout<<b<<endl;
delete s;
}
/*Error Message
)t$1EDE
D$$9uރ
[^_]Ë$ÐUSt1Ћu[]ÐUS
*** glibc detected *** ./a.out: free(): invalid pointer: 0xb7f81dc0 ***
*/
man4ish 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.