Here is my code which I would expect it to compile, but it does not:
#include <stdio.h>
#include <stdlib.h>
typedef struct turtle {
char name[20];
int age;
} turtle;
int main(){
turtle koray = {"koray",25};
turtle halim;
halim.name = "halim"; // This line will cause in compile error.
halim.age = 25;
printf("%s\n",koray.name);
printf("%s\n",halim.name);
}
What am I doing wrong?
This complies successfully, but prints garbage:
*(halim.name) = "halim";
by garbage I mean:
koray
p