I was curious why the following line of code doesnt work like I thought it would...assume the right files have been included and that str is a pointer to char:
Now I was under the impression that what this is doing is dereferencing str, thus meaning the particular element in that iteration, and then assigning that element the new upper case element.Code:int len = strlen(str); for (int i = 0; i < len; i++) *str++ = toupper(*str++);
What really happens is the program displays trash and I sit at my computer confused...hehe.
What I find even more interesting (ie: puzzling) is that when I changed the code to the following it works just fine even though I feel it is identical to the problem code:
Any insight is always appreciatedCode:int len = strlen(str); for (int i = 0; i < len; i++) *(str+i) = toupper(*(str+i));