Top "Struct" questions

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

Struct assignment or memcpy?

If I want to replicate a structure in another one (in C), what are the pro&con's of : struct1 = …

c struct variable-assignment memcpy
storage size of ‘names’ isn’t known

I get this error while compiling this .c source file /INIT_SOURCE_BUILD/src/names_list.c:7: error: storage size …

c struct typedef forward-declaration
How to create a new instance of a struct in C

In C, when you define a struct. What is the correct way to create a new instance? I've seen two …

c struct instance
c++ Initializing a struct with an array as a member

Edited again because it originally wasn't clear that I'm trying to initialize the arrays at compile time, not at run …

c++ struct initialization portability
Result of 'sizeof' on array of structs in C?

In C, I have an array of structs defined like: struct D { char *a; char *b; char *c; }; static struct …

c arrays struct sizeof
Marshal C++ struct array into C#

I have the following struct in C++: #define MAXCHARS 15 typedef struct { char data[MAXCHARS]; int prob[MAXCHARS]; } LPRData; And a …

c# c++ interop struct marshalling
Why can't we initialize members inside a structure?

Why can't we initialize members inside a structure ? example: struct s { int i = 10; };

c struct initialization member
Need help using qsort with an array of structs

Now, I have seen various examples, but I don't get what they mean. Here's my structure typedef struct profile{ char …

c arrays struct qsort
Can C++ struct have member functions?

I was pretty confused about the difference between struct and class as I seemed to see them used for pretty …

c++ class struct member-functions
How to read / write a struct in Binary Files?

I am facing a small problem. I have a struct, which has a vector. Note that the vector is dynamic …

c++ vector struct binaryfiles