Is there a function to substract certain charakters from a string?
My string contains masses of ';' between various characters that I want to process.
Thanx.
Printable View
Is there a function to substract certain charakters from a string?
My string contains masses of ';' between various characters that I want to process.
Thanx.
So you want everything in the string besides the ';'?
Sounds like a job for strtok. Google found me this: http://www.opengroup.org/onlinepubs/...sh/strtok.html
Here's a program :
Code:#include <string>
#include <iostream>
using std::string;
string strremove(const string& str, char rm)
{
string strnew;
for (string::size_type p = 0;p < str.length(); ++p)
if (str[p] != rm)
strnew += str[p];
return strnew;
}
int main()
{
string foo = ";;;;sang-;;;drax;;";
std::cout << strremove(foo,';');
}
I already tried strtok. It had Problems returning tokens like ' - + / '. Any Idea, why?
My lkv_String looks something like this:Code:lkv_Pointer = strtok (lkv_String, ";");
while (lkv_Pointer != NULL)
{
cout << lkv_Pointer << endl;
lkv_Pointer = strtok (NULL, ";");
}
Code:;;;;;;;;;;;;-20;;;;;;+60;;;;;;;;-30;;;;;;;;
Sorry! Ignore my last post - found mistake.
Thanks for all replies!
you're using string classes, right? if you search google i think there's a list of member functions for that, some which may help you here.