Given a string , say ,
char *str = \"Hello,StackOverflow!\"
char newStr[30];
int l = strlen(str);
for(int i =0 ; i
No. It invokes undefined behavior - it means it doesn't have to crash - it can do literally anything, like nasal demons.
Also, "gives a runtime error" - well, that depends on what do you mean by a runtime error. There's no dynamic runtime for C - if you expect a nicely formatted error message from an exception, that wouldn't happen. What would happen is most likely a segmentation fault.
All in all, if one causes/uses undefined behavior, he must not rely on it crashing or not crashing.