Top "Struct" questions

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

Copying one structure to another

I know that I can copy the structure member by member, instead of that can I do a memcpy on …

c struct copy
How to set default values in Go structs

There are multiple answers/techniques to the below question: How to set default values to golang structs? How to initialize …

go struct initialization default-value
Incompatible implicit declaration of built-in function ‘malloc’

I'm getting this error: warning: incompatible implicit declaration of built-in function ‘malloc’ I am trying to do this: fileinfo_list* …

c struct malloc
Assign one struct to another in C

Can you assign one instance of a struct to another, like so: struct Test t1; struct Test t2; t2 = t1; …

c struct
Initializing a struct to 0

If I have a struct like this: typedef struct { unsigned char c1; unsigned char c2; } myStruct; What would be the …

c struct initialization
Function for C++ struct

Usually we can define a variable for a C++ struct, as in struct foo { int bar; }; Can we also define …

c++ function struct
Why Choose Struct Over Class?

Playing around with Swift, coming from a Java background, why would you want to choose a Struct instead of a …

swift class struct design-principles
Struct inheritance in C++

Can a struct be inherited in C++?

c++ inheritance struct
Struct with template variables in C++

I'm playing around with templates. I'm not trying to reinvent the std::vector, I'm trying to get a grasp of …

c++ class templates struct
How to check for an empty struct?

I define a struct ... type Session struct { playerId string beehive string timestamp time.Time } Sometimes I assign an empty session …

struct go