assign directly will report an error:
int main() {
char str[5] = "hello";
str = "lautturi"; //error
printf("%s",str);
return 0;
}
error information:
main.c|18|error: assignment to expression with array type|
To work around, use the strcpy function:
/*
Example: Change char array in C language
*/
#include <stdio.h>
#include <stdlib.h>
int main() {
char str[5] = "hello";
strcpy(str, "lautturi");
printf("%s",str);
return 0;
}