my upit() using toupper() in cctype.h
cant get my upit() function to work! cant find anything wrong.
Code:
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;
class String //user-defined string type
{
private:
char* str; //pointer to string
public:
String(char* s)
{
int length = strlen(s); //length of string argument
str = new char[length+1]; //get memory
strcpy(str,s); //copy string
}
~String()
{
cout << "Deleting str.\n";
delete[] str;
}
void upit() //convert to uppercase if necessary
{
int length = strlen(str);
for(int i = 0; i <= length; i++)
toupper(*str+i);
//int i = 0;
//while( *(str+i) != '\0' )
//{
// toupper(*(str+i));
// i++;
//}
}
void display() //display the string
{
cout << str << endl;
}
};
ive made 2 attempts in the upit() both of them dont work. can anyone give me a kick in the face to the right direction? thanks in advance. :)