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 8431767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:56:39+00:00 2026-06-10T05:56:39+00:00

Possible Duplicate: Purpose of struct, typedef struct, in C++ typedef struct vs struct definitions

  • 0

Possible Duplicate:
Purpose of struct, typedef struct, in C++
typedef struct vs struct definitions

I am aware that there are two ways of declaring structs in C

struct point{
    int x, y;
};

and:

typedef struct{
    int x, y;
} point;

but what is the difference between these two methods and when would I use the typedef method and not the other ?

  • 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-10T05:56:41+00:00Added an answer on June 10, 2026 at 5:56 am

    There is only one way to declare a struct in C, using the struct keyword, optionally followed by the name of the structure, then followed by the member fields list in braces. So you could have:

      struct point_st {
         int x, y;
      };
    

    Here point_st is the name (or tag) of your structure. Notice that structure names have a different namespace in C than types (this is different in C++). So I have the habit of suffixing structure names with _st as shown above.

    You can (independently) define a type name using typedef, e.g.

      typedef struct point_st Point;
    

    (you can use typedef on any C type, BTW).

    For exemple Gtk and Glib has a lot of opaque types which are such opaque structures; only the implementation knows and cares about the structure members.

    Of course the compiler needs to know the field of a structure to allocate it; but if you only use pointers to an opaque structure, you don’t need to declare the structure (i.e. its fields in braces).

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

Sidebar

Related Questions

Possible Duplicates: Purpose of struct, typedef struct, in C++ typedef struct vs struct definitions
Possible Duplicate: Why doesn't delete set the pointer to NULL? Is there any purpose
Possible Duplicate: What is the purpose of a self executing function in javascript? Please,
Possible Duplicate: Objective C for Windows iPhone development on Windows Is there any way
Possible Duplicate: Why isn’t sizeof for a struct equal to the sum of sizeof
Possible Duplicate: What is the purpose of the Assemblies node in Web.Config? I removed
Possible Duplicate: What is the purpose of the expression “new String(…)” in Java? I've
Possible Duplicate: What is the purpose of a marker interface? Is it bad practice
Possible Duplicate: HTML Compress File Upload? I have complains from client that my website
Possible Duplicate: What are the differences between struct and class in C++ http://www.cplusplus.com/reference/std/typeinfo/type_info/ I

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.