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 by Per C.

quizTest Your Knowledge

Which file format is best for displaying file icons?

A
JPEG
0%
B
GIF
0%
C
PNG
0%
D
BMP
0%
Correct! Incorrect!     View the PNG definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Struct on this page is an original definition written by the TechTerms.com team. If you would like to reference this page or cite this definition, please 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 this definition or would like to suggest a new technical term, please contact us.

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.