Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Newbie C++, need help in capitalisation

Reply
Thread Tools

Newbie C++, need help in capitalisation

 
 
Robbo
Guest
Posts: n/a
 
      10-12-2004
Hi, I need to know how to turn a string into Upper case letters even
if the input is in lower.

E.g. say i was entering a name in a program and i typed john smith, i
need it to come out as John Smith.

Any idea on how this is done?

Many Thanks
 
Reply With Quote
 
 
 
 
Tim Love
Guest
Posts: n/a
 
      10-12-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Robbo) writes:

>Hi, I need to know how to turn a string into Upper case letters even
>if the input is in lower.


>E.g. say i was entering a name in a program and i typed john smith, i
>need it to come out as John Smith.


>Any idea on how this is done?

Try searching for
toupper C++
in Google, or reading previous items in this newsgroup.
 
Reply With Quote
 
 
 
 
Sumit Rajan
Guest
Posts: n/a
 
      10-12-2004
Robbo wrote:
> Hi, I need to know how to turn a string into Upper case letters even
> if the input is in lower.
>
> E.g. say i was entering a name in a program and i typed john smith, i
> need it to come out as John Smith.
>
> Any idea on how this is done?
>
> Many Thanks

#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>

int main()
{
std::string str("john smith");
std::transform(str.begin(),str.end(),str.begin(),s td::toupper);
std::cout << str << '\n';
}


--
Sumit Rajan <sumit DOT rajan AT gmail DOT com>
 
Reply With Quote
 
Sumit Rajan
Guest
Posts: n/a
 
      10-12-2004
Sumit Rajan wrote:
> Robbo wrote:
>
>> Hi, I need to know how to turn a string into Upper case letters even
>> if the input is in lower.
>>
>> E.g. say i was entering a name in a program and i typed john smith, i
>> need it to come out as John Smith.
>>
>> Any idea on how this is done?
>>
>> Many Thanks

>
> #include <iostream>
> #include <string>
> #include <cctype>
> #include <algorithm>
>
> int main()
> {
> std::string str("john smith");
> std::transform(str.begin(),str.end(),str.begin(),s td::toupper);
> std::cout << str << '\n';
> }
>
>


I just re-read your post. I had initially thought you wanted all caps in
the result. If you need to capitalize only the first letter of every
word, the answer still is std::toupper(). Only a few more lines of code. :-;


--
Sumit Rajan <sumit DOT rajan AT gmail DOT com>
 
Reply With Quote
 
Pedro Graca
Guest
Posts: n/a
 
      10-12-2004
Robbo wrote:
> E.g. say i was entering a name in a program and i typed john smith, i
> need it to come out as John Smith.


How do you deal with "John von Neumann"?


--
USENET would be a better place if everybody read:
http://www.expita.com/nomime.html
http://www.netmeister.org/news/learn2quote2.html
http://www.catb.org/~esr/faqs/smart-questions.html
 
Reply With Quote
 
puppet_sock@hotmail.com
Guest
Posts: n/a
 
      10-12-2004
Pedro Graca <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)-berlin.de>...
[snip]
> How do you deal with "John von Neumann"?


With a great deal of humility and respect.
(Sorry, it had to be done.)
Socks
 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      10-12-2004
(E-Mail Removed) wrote:
> Pedro Graca <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)-berlin.de>...
> [snip]
>
>>How do you deal with "John von Neumann"?

>
>
> With a great deal of humility and respect.
> (Sorry, it had to be done.)
> Socks


Or how about by only using Harvard architecture machines?
 
Reply With Quote
 
Pedro Graca
Guest
Posts: n/a
 
      10-12-2004
(E-Mail Removed) wrote:
> I (Pedro Graca) wrote...
> [snip]
>> How do you deal with "John von Neumann"?

>
> With a great deal of humility and respect.
> (Sorry, it had to be done.)
> Socks


Sorry if I hurt your feelings.
I just googled for "von" and typed the first name on the excerpts.
I've heard the name before but, to me, it's just any name that could be
the input to the function the OP is designing (I could just as well have
written "Pedro von Graca").

I just wanted the OP to have present that not everybody likes every part
of his/her name capitalized (or removed).


Unlike yours, my mail address is valid. If you want to continue this
conversation, please use e-mail.

--
USENET would be a better place if everybody read:
http://www.expita.com/nomime.html
http://www.netmeister.org/news/learn2quote2.html
http://www.catb.org/~esr/faqs/smart-questions.html
 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      10-13-2004

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Pedro Graca <(E-Mail Removed)> wrote in message
> news:<(E-Mail Removed)-berlin.de>...
> [snip]
>> How do you deal with "John von Neumann"?

>
> With a great deal of humility and respect.
> (Sorry, it had to be done.)
> Socks


After the second world war John von Neumann advocated a pre-emptive nuclear
strike on the Soviet Union before it had the chance to develop nuclear
weapons. He was also (reputedly) one of the inspirations for Dr Strangelove.
He was a genius but I'm not sure how much I respect him, I certainly
wouldn't want to show any humility.

John


 
Reply With Quote
 
Pedro Graca
Guest
Posts: n/a
 
      10-13-2004
Pedro Graca wrote:
> (E-Mail Removed) wrote:
>> I (Pedro Graca) wrote...
>> [snip]
>>> How do you deal with "John von Neumann"?

>>
>> With a great deal of humility and respect.
>> (Sorry, it had to be done.)
>> Socks

>
> Sorry if I hurt your feelings.

[shameful snip]

I have no idea what I was thinking.

Probably I read (about a dozen times) "What a great deal of
humility and respect." and not a direct answer to the question.


Please everybody accept my apologies, especially Socks.

--
USENET would be a better place if everybody read:
http://www.expita.com/nomime.html
http://www.netmeister.org/news/learn2quote2.html
http://www.catb.org/~esr/faqs/smart-questions.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
re_---need help Network Adapters!!!! NEED HELP!!!! hedayatniac@gmail.com Computer Support 4 08-13-2006 01:03 AM
USR2216 WiFi card causes Win XP to crash - newbie need help! David Leslie Wireless Networking 3 01-22-2005 05:17 PM
A novice (newbie) in need of help jbl Perl 2 12-16-2004 06:22 AM
Newbie C++, need help in capitalisation Robbo C++ 3 10-12-2004 07:46 PM
asp login, I need help please!! Newbie Patrick Hill ASP .Net 3 02-08-2004 08:18 AM



Advertisments