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.
gvijay1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sumant032199Connect With a Mentor Commented:
You will need to include CTYPE.H in your program. I would suggest you to go through some funcions like tolower() toupper() in CTYPE.H, which can solve the problem. The answer to your 1st question is tolower() function.
0
 
ArvindtnCommented:
Try this site, you will get a lot of information on STL.

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


0
 
nietodCommented:
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.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
eugene007Commented:
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



0
 
gvijay1Author Commented:
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
0
 
eugene007Commented:
#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
0
 
gvijay1Author Commented:
expert,
      I finally got it to work..Thanks..
0
 
eugene007Commented:
cool..:)

Regards

Eugene
0
All Courses

From novice to tech pro — start learning today.