Depends on how you store the name.
If it is a C string.
str[0] = toupper(str[0]);
If it is a std::string you might do:
std::string str = "hello world";
str[0] = toupper(str[0]);
or you might try something fancy and use transformations:
struct ToUpper {
char operator() (char c) const { return std::toupper(c); }
};
...
std::string str = "hello world";
std::transform(str.begin(),str.end(),str.begin(),ToUpper());
to convert the full string to upper case.
/Per W
On Mon, 6 Dec 2004, Alexsandro Meireles wrote:
> Hi, dev-c++ users,
>
> I have a very basic question I can't solve. I want to upper the first letter
> of a sentence. For example I have: "john is tall". I want to turn this into
> "John is tall". How do I do that?
>
> Thanks in advance!
>
> Alexsandro.
>
> _________________________________________________________________
> Natal no MSN Shopping: COMPROU, GANHOU $$! Veja Como!
> http://shopping.msn.com.br/MSNSHopping/GuiaEspeciais/Natal/conteudo.aspx?cd_guia=20&cd_funcao=238
>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|