I am trying to convert string characters to uppercase letters
int Main (zero) {int i = 0; Int n = 0; Stable char * str [] = {"Wow", "RACEACR", "No Satan lived.", "Rotor"}; For (i = 0; i
I got an error exc bad access, code 2
on the line where x [i] = c;
I did not find this error, why do I need to create another string and specify new string? Toupper returns the uppercase version of the character but actually did not change the element, so I'm not sure what Tupper has done with the returning element.
Your code tries to modify a string, which causes undefined behavior.
string "No evil lived."
non-convertible You must declare the array to help the compiler to catch the error:
Fixed four constants * str [] = {"Wow", // etc
For historical reasons, if you forget to include the const
, then the compiler will not want to break it It has to pass, but still it is an error, and some compilers will warn in any way.
You can use flag -write-string
to disable support for GCC for GCC; This will generate an error message for your code.
No comments:
Post a Comment