|
#include "stdafx.h"
#include "tstring.h"
void remove_char(tstring & s, TCHAR c)
{
LPTSTR text = (LPTSTR)s.c_str();
size_t size = _tcslen(text);
long idx = 0;
for(size_t i = 0;i < size;i ++)
if(text[i] != c)
{
text[idx] = text[i];
idx ++;
}
text[idx] = 0;
s.resize(idx);
}
void remove_chars(tstring & s, LPCTSTR symbols)
{
LPTSTR text = (LPTSTR)s.c_str();
size_t s_size = _tcslen(text);
size_t c_size = _tcslen(symbols);
long idx = 0;
for(size_t i = 0;i < s_size;i ++)
{
bool bAdd = true;
for(size_t k = 0;k < c_size;k ++)
if(text[i] == symbols[k])
{
bAdd = false;
break;
}
if(bAdd)
{
text[idx] = text[i];
idx ++;
}
}
text[idx] = 0;
s.resize(idx);
}
void remove_repeat(tstring & s, TCHAR c)
{
LPTSTR text = (LPTSTR)s.c_str();
size_t size = _tcslen(text);
long idx = 0;
bool bLastMatch = false;
for(size_t i = 0;i < size;i ++)
{
if(!bLastMatch || text[i] != c)
{
text[idx] = text[i];
idx ++;
}
bLastMatch = (text[i] == c);
}
text[idx] = 0;
s.resize(idx);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.