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 is a contributor for websites such as Webopedia.com and Enterprise Storage Forum. She writes about information technology security, networking, and data storage. Jenna lives in Nashville, TN.

Top Articles

The Complete List of 1500+ Common Text Abbreviations & Acronyms

From A3 to ZZZ we list 1,559 SMS, online chat, and text abbreviations to help you translate and understand today's texting lingo. Includes Top...

Windows Operating System History & Versions

The Windows operating system (Windows OS) refers to a family of operating systems developed by Microsoft Corporation. We look at the history of Windows...

How to Create a Website Shortcut on Your Desktop

Website Shortcut on Your Desktop reviewed by Web Webster   This Webopedia guide will show you how to create a website shortcut on your desktop using...

Generations of Computers (1st to 5th)

Reviewed by Web Webster Learn about each of the 5 generations of computers and major technology developments that have led to the computing devices that...

Pardot

What is Pardot? Pardot is a B2B marketing automation (MA) solution by Salesforce that...

Veeam

Veeam Software is a global vendor...

Akamai

Akamai Technologies is a global web technology company specializing in content...