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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

roupikCommented:
i=0;
while (*(string+i)) TOLOWER(string+i++);


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dhymesCommented:
roupik, This is not the way we play the game out here, you should not answer after someone else has added a comment. Also when you answer a question you need to answer the whole question.  
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

gvijay1Author Commented:
Roupik,
       To which of the above questions, is this answer. Please let me know
0
gvijay1Author Commented:
Roupik,
       Well, I figured out to which question that was and wrote a small code to see how it worked but the function did not work. Please let me know what you think the error iss..

//Code is Below
#include <iostream>
#include <string>
#include <vector>
#include <set>


main()
{
string Word;

cout<<"Enter the word here..."<<endl;
cin>>Word;

int i=0;

while (*(Word+i))
{
      TOLOWER(Word+i++);
}

cout<<"The new word is..."<<Word<<endl;

return 0;

}
0
roupikCommented:
problem is in TOLOWER(word+i++);

we need word+i before i++, but i++ runs eary :o( - so,
{ TOLOWER(word+i); i++; } can help

maybe ;o)

for(i=0;*(word+i);i++) TOLOWER(word+i);
0
gvijay1Author Commented:
Roupik,
       It is still giving me the same error and it is..C forbids comparison between an integer and a pointer. HMMMM!!!! I also included the ctype.h library, but it too does not work..Please give me further suggestions if possible.

0
gvijay1Author Commented:
Roupik,
       It is still giving me the same error and it is..C forbids comparison between an integer and a pointer. HMMMM!!!! I also included the ctype.h library, but it too does not work..Please give me further suggestions if possible.

0
gvijay1Author Commented:
Roupik,
       It is still giving me the same error and it is..C forbids comparison between an integer and a pointer. HMMMM!!!! I also included the ctype.h library, but it too does not work..Please give me further suggestions if possible.

0
3rsrichardCommented:
Try starting with something less elegant


// Funtest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <conio.h>
#include <ctype.h>
#include <string.h>

int main(int argc, char* argv[])
{

      char InString[80] = {78};
      char OutString[80];
      char *result;
      int i;
      int j;

// 1
      cprintf("Enter the string here ");
      result = _cgets(InString);
      printf( "\nLine length = %d\nText = %s\n", InString[1], result );

 
      for( i=0;i<InString[1];i++)
      {
            OutString[i] = tolower(InString[i+2]);
      };
      OutString[i] = 0;
      
      cprintf("\n\nThe new word is...     %s\n\n",OutString);


//2

      for( i=0,j=0;i<InString[1];i++)
      {
            OutString[j] = tolower(InString[i+2]);
            if(InString[i+2] != ' ')
                  j++;
      };

      OutString[j] = 0;
      
      cprintf("\n\nThe new word is...     %s\n\n",OutString);


//3
      OutString[0] = toupper(InString[2]);
      for( i=1;i<InString[1];i++)
      {
            OutString[i] = tolower(InString[i+2]);
            if(InString[i+1] == ' ')
                  OutString[i] = toupper(InString[i+2]);
      };

      OutString[i] = 0;
      
      cprintf("\n\nThe new word is...     %s\n\n",OutString);

return 0;


}

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.