Hello, I need to make an equivelant function as of string.erase(...)
Can someone help me?
Thanks!
Hello, I need to make an equivelant function as of string.erase(...)
Can someone help me?
Thanks!
Y3K Network http://www.y3knetwork.com
Bringing the software of the future on the net.
Equivalent function???
For what??? Your own string class?? A global function??
Equivelatn function for sting.erase(..)
I cant use string in a DLL as it crashes (discussed in a specific article)
So I have to make my own erase function taht works like the strings one. Get it now?
Any ideas?
Y3K Network http://www.y3knetwork.com
Bringing the software of the future on the net.
Well...um...is this for a string class you have implemented?
You just need a wrapper function around the string::erase method.
Try something like:
Notice that I have made the strng object static. This is important in maintaining the persistence of the return result.Code:char* serase(const char * s, int pos, int n); { static string str(s); str.erase(pos, n); return str.c_str(); }
Alternatively, you copy the result into a string pointer passed by argument.
Correction:
I think you may be better doing this, because of the static nature of str.
Code:char* serase(const char * s, int pos, int n); { static string str; str = s; str.erase(pos, n); return str.c_str(); }
Last edited by Davros; 10-15-2002 at 01:50 PM.
Why not just use memset()?
char myString[32];
strcpy(myString, "Hello World!");
cout << myString << endl;
memset(myString, 0, strlen(myString));
cout << myString << endl;