• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

String functions

Experts,
        I am just starting to explore into the STL library and had questions about some inbuilt functions.

(1) How do I convert all the characters in a string to lower-case.
(2) How do I remove blank lines between words in a string
(3) How do I convert 2 words (part of a string) which are both in small caps into one where the first character in each word has large caps.
0
gvijay1
Asked:
gvijay1
  • 2
  • 2
1 Solution
 
dsandfordCommented:
This is a duplicate question!
0
 
nietodCommented:
**************EXPERTS PLEASE NOTE*******************
This is a duplicate question probably asked by mistake.  Please do not answer here unless  gvijay1 indicates he/she wants an answer here.  Please post answers and comments on

http://www.experts-exchange.com/Computers/Programming/Languages/C++/Q_10264298.htm

instead.  

gvijay1 if this question was asked by mistake, delete it now and your points will be refunded.
0
 
danelroismanCommented:
you can use STL string member function

const E *c_str() const;
--------------------------

The member function returns a pointer to a nonmodifiable C string constructed by adding a terminating null element (E(0)) to the controlled sequence. Calling any non-const member function for *this can invalidate the pointer.

after this you can write somesing like this:

string myNewString =
_strlwr(_strdup(m_yourString.c_str()));

look about following functions in MSDN

_strlwr, _wcslwr, _mbslwr


0
 
danelroismanCommented:
you can use STL string member function

const E *c_str() const;
--------------------------

The member function returns a pointer to a nonmodifiable C string constructed by adding a terminating null element (E(0)) to the controlled sequence. Calling any non-const member function for *this can invalidate the pointer.

after this you can write somesing like this:

string myNewString =
_strlwr(_strdup(m_yourString.c_str()));

look about following functions in MSDN

_strlwr, _wcslwr, _mbslwr

2.

for remove blanks you can write utility function using the same way above:

char *  myNewChar = _strdup(m_yourString.c_str());

Run until '/0' and copy string ignoring
blanks.

your function can return new STL string



3.
It's hard to understand what the problem
!?
You can use solutions are above.


Daniel Roisman
0
 
nietodCommented:
Daniel,

Did you read the question history?  You should read all the comments before you post an answer.  And if you did, then why did you post an answer?  This question can no longer be deleted.  This just cost gvijay1 30 points.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now