Syntax

C Define a Struct Syntax

In C, define a struct: groups related fields — struct Point { int x, y; };

Quick Answer

Syntax
struct Point { int x, y; };
CSyntax

Define a Struct

Code example
struct Point { int x, y; };

Groups related fields.

Learn More

How to define a struct in C

  1. Open your C file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C Define a Struct Syntax

Use struct Point { int x, y; };.

Related Syntax References

Frequently asked questions

What is the C syntax for define a struct?

Use this pattern: struct Point { int x, y; };

Can I copy this C code example?

Yes. Use Copy code and adapt the example to your program.

Is this C syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify