Manipulate String

C

chessc4c6

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
 
M

Marc Aguilera

chessc4c6 said:
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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top