July 24th, 2013, 03:16 PM
Re: problem with toupper()
You still don't get the idea. You have to refer to documentation in every case when you face a problem.
Originally Posted by FenixRising
As long as you intend to just output the result of toupper, you never need this extra copy. Iteration along the original string, STL or plain C, whatever, will do for you.
Error 1 error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. - Which include file is strcpy_s in?
Another lesson: Learn to understand compiler messages. This one literally hints you on type incompatibility. The function wants input of int, but you provide pointer to char. Dereferencing the pointer might do the trick. Or using array-style access to string chars would work even better.
Error 2 error C2664: 'int toupper(int)' : cannot convert parameter 1 from 'const char *' to 'int' 35 1
The article toupper provides some sample you have to think over.
Another unpleasant surprise waits yet behind the corner. toupper returns int, so you're going to have a chain of char decimal codes here as the console print out. What would be your next move?
cout << toupper(cstr + i);
Tags for this Thread
Click Here to Expand Forum to Full Width