Hello,everyone.
I am learning the concept of pointers recently.
The reference book said when we declare a variable, * means a pointer.In common statement,* is used to transfer the value pointed by the pointer, and I am told that when * is used along with char (char*),it means a string.
But when I come across a certain program,it is very confusing to me, can anybody tell me what is the meaning behind each * in the program?
This program change every alpabet to capital letters.
char *toUpper(constchar* ptr) means that this is a function taking a char* argument and returnig a char*.
Here and in char *newStr the * means that variables used are pointers to chars ( C-Style strings ).
In *(newStr+i) = toupper(*(ptr+i)); * means that you are not using the value of the pointers but the values pointed.
Thank you very much.
But I found another problem. After using this little program,it outputs the capital letters, but just after that, it also transfer some strange things.
if i use "Happy Birthday", it will return "HAPPY BIRTHDAYGRh"
How can I eliminate those strang strings?
Thank you