Could some one share why below program crashes?
void main() { char *arr = "abcd"; arr[3] = 'f'; }
There is a difference between char * and char []! So this should work:
char *
char []
#include <stdio.h> int main() { char arr[] = "abcd"; arr[3] = 'f'; return 0; }
For further information see:
What is the difference between char s[] and char *s?