#include <stdio.h>
#include <stdlib.h>
struct student
{
    char name[15];
    long int regno;
struct employee
{
    char name1;
    int rollno;
    struct student s1
}s1;

}s2;
void main()
{
    struct student s1={"rohinn",2345}
    prntf("%s",s2.s1.name);



}

error at line 12

Recommended Answers

All 9 Replies

Semicolon. And you've been asked before to state what the error is. If you continue to post vague requests for help, I'll stop trying to help you.

the erros error12

Copy and paste the errors, don't post a screenshot.

Explain the problem -- don't make us try to figure it out.

You cannot nest structures.

ok my doubt is i have to just display the name as rohinn in the program using structure
these are following errors in the program
1.warning at line 16 return type of main is not int
2.error at line 18 syntax before "printf"
3.warning at line 17 unused variable s1

ok waltp why cant we nest structures????

Dude...start back at the hello world program, because you very clearly aren't getting it. You need to take a few steps back and start learning the basics again.

1.warning at line 16 return type of main is not int

Take one guess.

2.error at line 18 syntax before "printf"

Look at the line before printf. What's missing?

ok waltp why cant we nest structures????

Ask the people that designed the language. I never cared why. They said you can't so I don't.

And do what deceptikon suggests. Answering all these basic questions gets tiresome when all you have to do is study the material in your book.

ok thanks for ur reply memeber s i got correct output

#include <stdio.h>
#include <stdlib.h>
struct student
{
    char name[15];
    long int regno;
struct employee
{
    char namer;
    int rollno;

}s1;

}s2;
void main()
{
    struct student s1={"rohinn",'2345'};
    printf("%s",s1.name);




}
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.