Although this question is very simple, it will also make a lot of mistakes. You will know it at ordinary times, but it is easy to be silly during programming, and you will not be able to get it back...
It seems that you still need to write more code .. No nonsense.
Paste the Code directly ..
# Include <iostream> # include <string> using namespace STD; char * toupperchar (char * SRC) {int length = strlen (SRC ); char * m_dest = new char [Length + 1]; memset (m_dest, 0, Length + 1); memcpy (m_dest, SRC, length); int Index = 0; while (m_dest [Index]) {If (m_dest [Index]> 'A' & m_dest [Index] <'Z ') m_dest [Index] = m_dest [Index] + 'a'-'A'; index ++;} return m_dest;} void main () {char * m_src = "helloworld "; char * result = toupperchar (m_src); cout <result <Endl ;}
My Fan error:
1: char * src = "helloworld", I directly used SRC to change the value .. It's really second...
2: At that time, index was not used, but * m_dest ++ was used, which is a second place ..
Don't let this happen... Record...