I have written a program in C to lower a string when compile it in gcc, it crashes when run. But in MSVC program run smoothly.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *strlower(char *s){
for ( ; *s; ++s) *s = tolower(*s);
return (char *)s;
}
int main(){
char *c = "HELLO";
strlower(c);
printf("%s",c);
return 0;
}
if variable c
is array then program works in both compiler. Why not work when using pointer in gcc ?