Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std::string title case

Reply
Thread Tools

std::string title case

 
 
pkirk25
Guest
Posts: n/a
 
      11-08-2006
string name;
cin >> name;

User enters "johnny appleseeD".

How can I use transform to reformat this as "Johnny Appleseed"?

Thanks in advance.

 
Reply With Quote
 
 
 
 
mlimber
Guest
Posts: n/a
 
      11-08-2006
pkirk25 wrote:
> string name;
> cin >> name;
>
> User enters "johnny appleseeD".
>
> How can I use transform to reformat this as "Johnny Appleseed"?


Sounds like homework to me.

http://parashift.com/c++-faq-lite/ho...t.html#faq-5.2

Cheers! --M

 
Reply With Quote
 
 
 
 
Jacek Dziedzic
Guest
Posts: n/a
 
      11-08-2006
pkirk25 wrote:
> string name;
> cin >> name;
>
> User enters "johnny appleseeD".
>
> How can I use transform to reformat this as "Johnny Appleseed"?


You can't, because >> breaks the input on each whitespace,
i.e. name will only contain "johnny".

- J.
 
Reply With Quote
 
pkirk25
Guest
Posts: n/a
 
      11-08-2006

mlimber wrote:
> pkirk25 wrote:
> > string name;
> > cin >> name;
> >
> > User enters "johnny appleseeD".
> >
> > How can I use transform to reformat this as "Johnny Appleseed"?

>
> Sounds like homework to me.
>
> http://parashift.com/c++-faq-lite/ho...t.html#faq-5.2
>
> Cheers! --M


I'm 42 and long past homework. Thanks for taking the time to share you
expertise.

 
Reply With Quote
 
pkirk25
Guest
Posts: n/a
 
      11-08-2006

Jacek Dziedzic wrote:
> pkirk25 wrote:
> > string name;
> > cin >> name;
> >
> > User enters "johnny appleseeD".
> >
> > How can I use transform to reformat this as "Johnny Appleseed"?

>
> You can't, because >> breaks the input on each whitespace,
> i.e. name will only contain "johnny".
>
> - J.


I didn't know that. The actual phrases I need to reformat are in
format "darkmoon faire-alliance" and I'd like to change them to
"Darkmoon Faire: Alliance". The colon is easy but the correct use of
transform is not.

 
Reply With Quote
 
Nate Barney
Guest
Posts: n/a
 
      11-08-2006
pkirk25 wrote:
> The actual phrases I need to reformat are in format "darkmoon
> faire-alliance" and I'd like to change them to "Darkmoon Faire:
> Alliance". The colon is easy but the correct use of transform is
> not.


I probably wouldn't use std::transform for that. Take a look at boost
(http://www.boost.org/libs/libraries.htm#String), particularly its regex
library, and see if that might suit your needs.

Nate
 
Reply With Quote
 
Jim Langston
Guest
Posts: n/a
 
      11-09-2006
"pkirk25" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> string name;
> cin >> name;
>
> User enters "johnny appleseeD".
>
> How can I use transform to reformat this as "Johnny Appleseed"?
>
> Thanks in advance.


I would probably write my own function to do the convertion, I don't think
transform would do it.


 
Reply With Quote
 
pkirk25
Guest
Posts: n/a
 
      11-09-2006

Jim Langston wrote:
> "pkirk25" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> > string name;
> > cin >> name;
> >
> > User enters "johnny appleseeD".
> >
> > How can I use transform to reformat this as "Johnny Appleseed"?
> >
> > Thanks in advance.

>
> I would probably write my own function to do the convertion, I don't think
> transform would do it.


Easy enough - thanks.

 
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
Friendly Urls with page title in (eg. page-title.aspx) anthonykallay@googlemail.com ASP .Net 1 04-24-2007 08:25 AM
How 2 place page title into window title using sitemap in master page? bednar.tomas@gmail.com ASP .Net 0 11-30-2006 03:17 PM
Does anyone know the title of the first ever DVD title released? (UK/US) Mikey DVD Video 12 09-23-2006 07:14 PM
Rendering proper case/title case on bound data in datagrid? ASP .Net Web Controls 1 12-25-2004 01:27 AM
Fastest way to get a the string between <title> </title> Andreas Klemt ASP .Net 1 08-10-2003 01:58 AM



Advertisments