How to access structure variables in nested structures

#include<stdio.h>
typedef struct contact
{
        char name[1][20];
        struct number
        {
                double num;
        }no;
};

Now how to access num ,can anyboddy explain me?

Recommended Answers

All 2 Replies

you had an error in your structure declaration and a questionable variable.

#include<stdio.h>

#include<stdio.h>
typedef struct contact
{
        char name[1][20];/*why do you have this*/
        struct number
        {
                double num;
        }no;
} myc;

int main()
{
	myc thec;
	thec.no.num = 1234;

	fprintf(stdout, "num->%f\n", thec.no.num);
	
	return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.