Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9211995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:25:28+00:00 2026-06-18T01:25:28+00:00

int main() { int a; typedef struct { int i; int j; }type1; typedef

  • 0
int main()
{
  int a;
  typedef struct  
  {
      int i;
      int j;
  }type1;
  typedef type1 type[10]; //Please explain this line ?
  typedef struct 
  {
      int  l;
      type  c;
  }type2;

  type2 x;
  x.c[0].i=1;   //How can we write this??
  x.c[0].j=2;

  x.c[2].j=3;

  printf("%d",x.c[2].j);
  return 0;
}

Program is compiling successfully which I’m expectecting not to because of

    typedef type1 type[10];

Please explain the behavior of typeded here.All I know is that we can define an alias with the help of typedef.

output:3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:25:29+00:00Added an answer on June 18, 2026 at 1:25 am

    The way to read typedef is as a regular variable declaration, with the variable’s type being the type that is being given an alias, and the variable name being the name of the new alias.

    So, in

    typedef type1 type[10];
    

    if we drop the typedef we get:

    type1 type[10];
    

    This clearly defines type to be an array of 10 type1. So, the typedef is then introducing the name type for the type “array of 10 type1“.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

int main() { int *d=0; printf(%d\n,*d); return 0; } this works fine. >cc legal.c
#include <stdio.h> typedef struct { short x,y; char type; } Tile; int main(int argc,
Please have a look at this program #include<stdio.h> #include<string.h> typedef struct hs_ims_msrp_authority { int
typedef struct Value{ int id; char type; char a; } Value; void fooV(Value v){
I have a dictionary that goes like this: typedef struct dictNode { int key;
void main() { typedef boost::ptr_map<int, char> MyMap; //typedef std::map<int, char *> MyMap; // in
int main() { char *p,c; for(p=Hello World;c=*p;++p) { printf(%c,c); } } In the above
I'm having some troubles understanding MPL placeholders. Could someone please explain me why this
Consider the following code template<typename T, int N> struct A { typedef T value_type;
error: dereferencing pointer to incomplete type The problem line is gl->point[0] = (struct list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.