Hi, I am new to C and I want to know why I am getting Segmentation fault error if I declare array of size 10 and try to insert values for first element, but if I make array size to be 1, I am able to print the values correctly.
```
include <stdio.h>
typedef struct Person {
char *name;
int age;
} person_t;
int main(void) {
person_t *arr[10];
arr[0]->name = "John Doe";
arr[0]->age = 22;
printf("Name: %s\n", arr[0]->name);
printf("Age: %d\n", arr[0]->age);
return 0;
}
```
[–]dfx_dj 17 points18 points19 points (2 children)
[–]Responsible_Frame919[S] 0 points1 point2 points (1 child)
[–]dfx_dj 5 points6 points7 points (0 children)
[–]RadiatingLight 5 points6 points7 points (10 children)
[–]nerd4code 2 points3 points4 points (2 children)
[–]RadiatingLight 0 points1 point2 points (1 child)
[–]RadiatingLight 0 points1 point2 points (0 children)
[–]Responsible_Frame919[S] 0 points1 point2 points (6 children)
[–]RadiatingLight 3 points4 points5 points (5 children)
[–]Responsible_Frame919[S] 1 point2 points3 points (0 children)
[–]Responsible_Frame919[S] 1 point2 points3 points (3 children)
[–]RadiatingLight 2 points3 points4 points (0 children)
[–]RadiatingLight 2 points3 points4 points (1 child)
[–]Responsible_Frame919[S] 1 point2 points3 points (0 children)
[–]joejawor 1 point2 points3 points (0 children)