Struct

A struct (short for structure) is a data type available in C programming languages, such as C, C++, and C#. It is a user-defined data type that can store multiple related items. A struct variable is similar to a database record since it may contain multiple data types related to a single entity.

Below is an example of an article defined as a struct in the C programming language.

struct Article
{
    int    articleID;
    char   title[120];
    char   date[10];
    char   author[60];
    char   content[4000];
}

The above struct "Article" contains both integer and character array data types. It can be used to store all the information about an article in a single variable. Since structs group the data into a contiguous block of memory, only a single pointer is needed to access all the data of a specific article.

Structs are similar to classes used in object oriented programing languages, such as Objective C and C#. The primary difference between the two data structures is that structs are public while classes are private by default. That means struct variables can be accessed and modified by any function within the code, while classes may only be accessed by the function in which they are defined.

Updated November 21, 2015

Definitions by TechTerms.com

The definition of Struct on this page is an original TechTerms.com definition. If you would like to reference this page or cite this definition, you can use the green citation links above.

The goal of TechTerms.com is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about the Struct definition or would like to suggest a new technical term, please contact us.

Want to learn more tech terms? Subscribe to the daily or weekly newsletter and get featured terms and quizzes delivered to your inbox.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.