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.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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
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
#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
ASKER
expert,
I finally got it to work..Thanks..
I finally got it to work..Thanks..
cool..:)
Regards
Eugene
Regards
Eugene
http://www.dinkum.com/htm_stl/index.html