Manipulate String

Discussion in 'C++' started by chessc4c6, Apr 8, 2005.

  1. chessc4c6

    chessc4c6 Guest

    As part of a programming assignment, I am supposed to create a my own
    toUpper and toLower class functions, This is my piece of code:

    void Mystring::toUpper(char *s1){
    char *cpy = theString = new char[strlen(s1)+1];
    char lower = 'a';
    char higher = 'A';
    while(!s1++){
    if(s1==lower)
    s1=higher;
    lower++
    higher++;
    }
    }

    and this is my returnString function:

    char* Mystring::returnString(){
    return theString ;
    }

    But when I return the string, I just get gibberish on the screen...can
    someone please help me out and just guide me in the right direction
     
    chessc4c6, Apr 8, 2005
    #1
    1. Advertising

  2. "chessc4c6" <> wrote in message news:<>...
    > As part of a programming assignment, I am supposed to create a my own
    > toUpper and toLower class functions, This is my piece of code:
    >
    > void Mystring::toUpper(char *s1){
    > char *cpy = theString = new char[strlen(s1)+1];
    > char lower = 'a';
    > char higher = 'A';
    > while(!s1++){
    > if(s1==lower)
    > s1=higher;
    > lower++
    > higher++;
    > }
    > }
    >
    > and this is my returnString function:
    >
    > char* Mystring::returnString(){
    > return theString ;
    > }
    >
    > But when I return the string, I just get gibberish on the screen...can
    > someone please help me out and just guide me in the right direction


    the answer's in the book you took this code snip from.
    Just that!
     
    Marc Aguilera, Apr 9, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    1
    Views:
    332
    Mike Wahler
    Jan 22, 2005
  2. Chris

    manipulate string

    Chris, Oct 28, 2003, in forum: Python
    Replies:
    14
    Views:
    529
    Michel Claveau/Hamster
    Oct 28, 2003
  3. manipulate string

    , Oct 27, 2005, in forum: C Programming
    Replies:
    6
    Views:
    455
    Dave Thompson
    Nov 7, 2005
  4. Mike Gleason jr Couturier

    Manipulate HTML string as DOM

    Mike Gleason jr Couturier, Mar 28, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    1,188
    Mike Gleason jr Couturier
    Mar 28, 2008
  5. Andre

    Macro to manipulate chars inside string

    Andre, Feb 3, 2010, in forum: C Programming
    Replies:
    19
    Views:
    1,179
    Eric Sosman
    Feb 5, 2010
Loading...

Share This Page