0

I am trying to initialize a string in C on this code :

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#pragma warning(disable:4996)

struct person{
    char name[10];
    int id;
}; typedef person_t;

struct family{
    person_t father;
    person_t mother;
    person_t kid[10];
}; typedef family_t;

void main()
{
     family_t fam;
     fam.father.name = "sdsd";
}

This code gives me C-2224 Eror. How do i access eache struct of type person_t that are inside the struct of type family_t?

3
  • 2
    The problem isn't about struct within a struct, but that you can't assign to an array, only copy to it. Commented Oct 17, 2017 at 12:10
  • fam.father.name = "sdsd";-> strcpy(fam.father.name, "sdsd"); Commented Oct 17, 2017 at 12:16
  • yahh if find that there were to many ; in the struct. Commented Oct 17, 2017 at 12:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.