here i kno trim function wil remove first and last whitespaces if occured. but i don the program for that.string wil u pleas explain this program step by step?
particularly why they take the concept of takin condition >' ' in conditional statement.
program: i didnt send main,class definition simply function definition
[code=cpp]
string StringUtil::Tri m(string givenString)
{
int count = givenString.len gth();
if (count == 0 || (givenString[0] > ' ' && givenString[count-1] > ' '))
return givenString;
int preTrim = 0;
for (;; preTrim++)
{
if (preTrim == count)
return givenString;
if (givenString[preTrim] > ' ')
break;
}
int endTrim = count;
while (givenString[endTrim-1] <= ' ')
endTrim--;
return this->SubString(give nString, preTrim, endTrim-1);
};[/code]
particularly why they take the concept of takin condition >' ' in conditional statement.
program: i didnt send main,class definition simply function definition
[code=cpp]
string StringUtil::Tri m(string givenString)
{
int count = givenString.len gth();
if (count == 0 || (givenString[0] > ' ' && givenString[count-1] > ' '))
return givenString;
int preTrim = 0;
for (;; preTrim++)
{
if (preTrim == count)
return givenString;
if (givenString[preTrim] > ' ')
break;
}
int endTrim = count;
while (givenString[endTrim-1] <= ' ')
endTrim--;
return this->SubString(give nString, preTrim, endTrim-1);
};[/code]
Comment