Struct

A struct, or structure, in C programming languages is a container that holds variables of different data types that can be accessed together. Structs are helpful because they can categorize and group related data. Structs occur in C programming languages, which include C# and C++.

To initiate and use a struct, first declare the struct and place an optional title (or tag) before it:

struct Title { } ;

Then place a semicolon at the end of the struct.

Structs contain variables, which identify the specific piece of data with which they’re paired within the struct. Some common variables in C programming include int, char, and float, which indicate the data type they store. For example, if one struct holds data about one particular customer in a business, the variable char might relate to the customer’s name, while int (integer) contains their specific customer ID number. The specific information that a variable stores is known as a value. Structs provide a method of grouping related (or perhaps unrelated) data in an organized format.

To access data in a struct, use a member operator (often a period) between the variable and the specific data member. You can also use a pointer to locate data stored in a struct. Pointers use the memory address of a variable, which has been programmed within the struct, to locate that variable’s corresponding data.






Jenna Phipps
Jenna Phipps
Jenna Phipps is a writer for Webopedia.com, Enterprise Storage Forum, and CIO Insight. She covers data storage systems and data management, information technology security, and enterprise software solutions.
Get the Free Newsletter
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.
Get the Free Newsletter
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.

Related Articles

Virtual Private Network (VPN)

A virtual private network (VPN) encrypts a device's Internet access through a secure server. It is most frequently used for remote employees accessing a...

Gantt Chart

A Gantt chart is a type of bar chart that illustrates a project schedule and shows the dependency between tasks and the current schedule...

Input Sanitization

Input sanitization is a cybersecurity measure of checking, cleaning, and filtering data inputs from users, APIs, and web services of any unwanted characters and...

IT Asset Management Software

IT asset management software (ITAM software) is an application for organizing, recording, and tracking all of an organization s hardware and software assets throughout...

ScalaHosting

ScalaHosting is a leading managed hosting provider that offers secure, scalable, and affordable...

HRIS

Human resources information system (HRIS) solutions help businesses manage multiple facets of their...

Best Managed Service Providers...

In today's business world, managed services are more critical than ever. They can...