Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,945 questions

51,887 answers

573 users

How to use nested structure in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>

struct user {
	char name[32];
	int id;
 
	struct BirthDay{
		int dd;
		int mm;
		int yyyy;
	}BD;
};
 
int main()
{
	struct user u;
 
    strcpy(u.name, "yopyop");
	u.id = 128729;
	
	u.BD.dd = 14;
	u.BD.mm = 3;
	u.BD.yyyy = 1976;
	
	printf("\nName: %s\nid: %d\nBirthDay: %02d/%02d/%02d", u.name, u.id, u.BD.dd, u.BD.mm, u.BD.yyyy);
 
	return 0;
}



 
/*
run:
 
Name: yopyop
id: 128729 
BirthDay: 14/03/1976
 
*/
 

 



answered Aug 22, 2021 by avibootz

Related questions

1 answer 77 views
77 views asked Jun 7, 2024 by avibootz
2 answers 134 views
1 answer 153 views
1 answer 115 views
1 answer 117 views
117 views asked Aug 23, 2021 by avibootz
2 answers 232 views
...