Top "Struct" questions

A keyword in various programming languages whose syntax is similar to or derived from C (C++, C#, Swift, Go, Rust, etc.

Why isn't sizeof for a struct equal to the sum of sizeof of each member?

Why does the sizeof operator return a size larger for a structure than the total sizes of the structure's members?

c++ c struct sizeof c++-faq
How to correctly assign a new string value?

I'm trying to understand how to solve this trivial problem in C, in the cleanest/safest way. Here's my example: #…

c string struct strcpy
Proper way to initialize C++ structs

Our code involves a POD (Plain Old Datastructure) struct (it is a basic c++ struct that has other structs and …

c++ struct initialization valgrind calloc
Copy struct to struct in C

I want to copy an identical struct into another and later on use it as a comparance to the first …

c struct copy microchip
default value for struct member in C

Is it possible to set default values for some struct member? I tried the following but, it'd cause syntax error: …

c struct
C - function inside struct

Im trying to create a function inside a structure, so far i have this code: typedef struct client_t client_…

c function struct
How do I check if a variable is of a certain type (compare two types) in C?

In C (not C++/C#) how do I check if a variable is of a certain type? For example, something …

c types struct
Initialize/reset struct to zero/null

struct x { char a[10]; char b[20]; int i; char *c; char *d[10]; }; I am filling this struct and then using …

c struct initialization
How do you compare structs for equality in C?

How do you compare two instances of structs for equality in standard C?

c struct equality
Structs in Javascript

Previously, when I needed to store a number of related variables, I'd create a class. function Item(id, speaker, country) { …

javascript struct