I'm getting strange output when I print a conversion to upper and lower....here it is:
22. Testing: CaseString class.
s22 "BaLLooN" String Length: 7
Lower Case:
büllÅÅn
Upper Case:
t22 "BaLLooN" String Length: 7
Lower Case:
büllÅÅn
Upper Case:
u22 "BaLLooN" String Length: 7
Lower Case:
büllÅÅn
Upper Case:
Press any key to continue.
I have no idea why, I'm staring at the msdn and it looks like I'm doing everything right m_buf is coming from a String class of which this Case class is derived. Just an ordinary string buffer.....
Code:
#include "stdafx.h"
#include "string.h"
#include "case.h"
Case::Case() : String()
{
}
Case::Case(const Case& cs) : String(cs)
{
}
Case::Case(char* str) : String(str)
{
}
Case::~Case()
{
if(NULL != m_name)
{
delete[]m_name;
m_name=NULL;
}
if(NULL != m_buf)
{
delete[]m_buf;
m_buf=NULL;
}
}
Case& Case::operator=(const Case& cs)
{
if(this == &cs)
{
return *this;
}
String::operator=(cs);
m_length = cs.m_length;
if(NULL != m_buf)
{
delete[]m_buf;
m_buf = NULL;
}
m_buf = new char[m_length + 1];
strcpy_s(m_buf, m_length + 1, cs.m_buf);
return *this;
}
void Case::print()
{
m_lower = m_buf;
m_upper = m_buf;
cout << m_name << " \""<< m_buf << "\" String Length: " << getLength() << endl;
cout << "Lower Case: " << endl;
if(isupper (*m_lower))
{
for( m_lower; m_lower < m_buf + strlen(m_buf); m_lower++ )
{
putchar( _tolower( *m_lower ) );
}
}
cout << endl;
cout << "Upper Case: "<< m_lower<< endl;
if(islower (*m_upper))
{
for( m_upper; m_upper < m_buf + strlen(m_buf); m_upper++ )
{
putchar( _toupper( *m_upper ) );
}
}
cout << endl;
}
Am I just messing the obvious???