#include <stdio.h>
int main(void) {
int arr[10];
arr = "Hello";
printf("%s",arr);
return 0;
}
The above code shows compiler error:
t.c: In function ‘main’:
t.c:5:9: error: assignment the expression including array type arr = "Hello";
^
t.c:6:12: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 got make ‘int *’ [-Wformat=]
printf("%s",arr);
^
Whereas the below code works fine.
#include <stdio.h>
int main(void) {
charis arr[10] = "Hello";
printf("%s",arr);
return 0;
}
Both look identical at me. What am MYSELF missing here?