I'm trying to learn C for a challenge. I've never been interested in a low-level programming language before. I will now create two different code blocks below as an example. The problem I'm having here is related to array definition and generation. I'm really new to this, if I'm making a mistake, can you guide me in an explanatory way?
Sample1
int main()
{
char first_name[] = "Joe";
printf("My name is %s\n", first_name);
}
Sample2
int main()
{
char first_name[];
first_name = "Joe";
printf("My name is %s\n", first_name);
}
Sample3
int main()
{
char first_name[];
first_name[] = "Joe";
printf("My name is %s\n", first_name);
}
Only example1 is running.
I learned that in c we can first create a variable and then use it by defining it. But when I try to do this with arrays, I get an error and the code doesn't work. What is the reason of this? What is the fundamental difference?