Link to home
Start Free TrialLog in
Avatar of gvijay1
gvijay1

asked on

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.
Avatar of Arvindtn
Arvindtn

Try this site, you will get a lot of information on STL.

http://www.dinkum.com/htm_stl/index.html


FYI The EE guidelines specifically state that you should ask only 1 question per question   (this is 3).  furthermore each of these questions are probalby worth 50 points, at least 30 points a piece.
ASKER CERTIFIED SOLUTION
Avatar of sumant032199
sumant032199
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
1) islover()  
2) ispunct()
3) isupper()
4) isspace()
5) isdigit()
6) isalpha()


This are the character classification and conversion facilities in ctype library. In your case you could use the option 1,4,3. Its all up to you now to utilize this function. Please include the #include<ctype.h> header file in your program.


Regards

Eugene



Avatar of gvijay1

ASKER

Eugene,
       I tried isupper(string) and it does not work. I also tried string.isupper() and it also does not work. I have a feeling that this is part of c and not c++. Is there any function in C++ that can handle this conversion?

GVijay1
#include <ctype.h>
#include <string.h>

void main(void)
{
    //You can place this coding
    //where ever you feel its right
    //to be placed. It does not always
    //have to reside in the place where
    //i have specified.

    char chStr[10] = "SE100";
    int k = strlen(chStr);
    for (int i = 0; i <= k ; i++)
    {
       if (isalpha(chStr[i]))
       {
          AfxMessageBox("Character");
       }
       else if(isalnum(chStr[i]))
       {
          AfxMessageBox("Number");
       }
    }
}


Try this program first in you visual c++ and let me know what is the result..:)


Regards

Eugene
Avatar of gvijay1

ASKER

expert,
      I finally got it to work..Thanks..
cool..:)

Regards

Eugene