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

  • Home
  • SEARCH
  • 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 8880195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:07:18+00:00 2026-06-14T20:07:18+00:00

Im studying C language and trying to learn some about Structs, I have this

  • 0

Im studying C language and trying to learn some about Structs, I have this example below and Im trying to see how the struct memory allocation is composed. I have learned that every field in a struct is wordsized so that if not enough memory is used there will be empty memory spaces which should be seen in the example, but the compiler gives me several error like Type specifier missing, Expected ‘, and Type name requieres specifier or qualifier. How come?

#include <stddef.h>
#include <stdio.h>

typedef struct
{
    char name[25];
    int id;
    int year;
    char material;
} Student;

int
main(void)
{
    Student talu;
    printf("Size of tAlu %d\n", (int)sizeof(talu));
    printf("name size is %d\n", offsetof(talu, name));
    printf("id size is %d\n", offsetof(talu, id));
    printf("year size is %d\n", offsetof(talu, year));
    printf("material size is %d\n", offsetof(talu, material));
    return 0;
}
  • 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-14T20:07:19+00:00Added an answer on June 14, 2026 at 8:07 pm

    I also tried compiling your code and got errors, so I ended up fixing it like this:

    #include <stddef.h>
    #include <stdio.h>
    
    typedef struct
    {
        char name[25];
        int id;
        int year;
        char material;
    } Student;
    
    int
    main(void)
    {
        printf("Size of tAlu %d\n", (int)sizeof(Student));
        printf("name size is %d\n", offsetof(Student, name));
        printf("id size is %d\n", offsetof(Student, id));
        printf("year size is %d\n", offsetof(Student, year));
        printf("material size is %d\n", offsetof(Student, material));
        return 0;
    }
    

    This is with using GCC as the compiler.

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

Sidebar

Related Questions

I have a little doubt about javascript, a new language that I'm studying... I
I am studying the MIPS assembly language and came across this example in the
I'm studying The C++ Programming Language from Bjarne Stroustrup and he talks about logical
While studying about JMX, I have seen one of the important feature of it
I am a Java developer trying to learn C++. I have many times read
I am studying for a final and have a few questions about RMI and
I`m currently studying C++ and want to learn another language. For work I use
Maybe some might find this, a hypothetical question. I have recently started development of
We were studying about compilers at college so this raised me curiosity that when
I just started studying programming about 6 months ago and I have really been

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.