Hello for all C++ programmers,
I think we write the fastest and smallest code requare for manipulating with strings like done in VB (Visual Basic).
If somebody know how to write other functions that work faster (like with ASM or C++) and use less code, add to this thread.
How to do InStr(), InStrRev() or other functions add if you know.
I think we write the fastest and smallest code requare for manipulating with strings like done in VB (Visual Basic).
If somebody know how to write other functions that work faster (like with ASM or C++) and use less code, add to this thread.
copy mid point from string
Code:
string Mid(string& str, int pos1, int pos2)
{
int i;
string temp = "";
for(i = pos1; i < pos2; i++)
{
temp += str[i];
}
return temp;
}
copy mid point vb style (pos + length)
Code:
string vMid(string& str, int pos1, int length)
{
int i;
string temp = "";
for(i = pos1; i < pos1+length; i++)
{
temp += str[i];
}
return temp;
}
copy from left of pos
Code:
string Left(string& str, int pos)
{
int i;
string temp = "";
for(i = 0; i < pos; i++)
{
temp += str[i];
}
return temp;
}
copy from right of pos
Code:
string Right(string& str, int pos)
{
int i;
string temp = "";
for(i = pos; i < strlen(str.c_str()); i++)
{
temp += str[i];
}
return temp;
}
lowercase the string
Code:
string Lcase(string& str)
{
int i;
string temp = "";
for(i = 0; i < str.length(); i++)
{
temp += tolower(str[i]);
}
return temp;
}
uppercase the string
Code:
string Ucase(string& str)
{
int i;
string temp = "";
for(i = 0; i < str.length(); i++)
{
temp += toupper(str[i]);
}
return temp;
}
How to do InStr(), InStrRev() or other functions add if you know.