Is there a problem with using char[ ] to declare my name variable in C?

36 Views Asked by At

I tried running this code on vscode but i'm getting this result in the image below. Can someone tell me what i am doing wrong. I asked chatgpt but i don't understand the response i'm getting. This is C language btw.

#include <stdio.h>

int main ()
{

    typedef struct
    {
        int age;
        char name[20];
    }person;

    person people [2];

    people[0].age = 25;
    people[0].name = "Barabas";


    people[1].age = 28;
    people[1].name = "Stella";
    
printf("%s" , people[1].name);
    return 0;

}

enter image description here

0

There are 0 best solutions below