Index:
[thread]
[date]
[subject]
[author]
From: Tim Bain <tpb2@duke.edu>
To :
Date: Tue, 09 Feb 1999 21:22:16 -0500
Re: tolower & other useful string functions....
Michael Abernethy wrote:
> I've looked through the STL and not found anything.
> I think writing the functions yourself wouldn't be that difficult.
>
> something like
>
> void lowercase(string & str)
> {
> int i;
> for (i=0; i<str.size(); i++)
> {
> if (str[i] < 'a')
> str[i] = str[i] +('a' - 'A');
> }
> }
You would want to make the if statement read:
if ((str[i]>='A')&&(str[i]<='Z'))
str[i] = str[i]+('a'-'A')
because there are a lot of non-letter characters that
are less than 'a', and you wouldn't want to change
them...
Tim
Index:
[thread]
[date]
[subject]
[author]