Category "struct"

C, Do structs with multiple dynamically allocated arrays need to be resized for every allocation?

Below I have a struct with multiple dynamically allocated char arrays. It compiles, Valgrind indicates no issues and it functions as anticipated. Earlier, someo

Does adding a star after a pointer struct definition make it a double pointer?

I have a struct typedef struct hash_entry_{ char *string; void *data; struct hash_entry *next; }hash_entry, *p_entry; I am referencing p_entry later i

Is there a way to use the #define directive to create a constant struct?

Let's say I have this struct typedef struct { int AM; char* name, surname; }Item; and I want to define a constant NULLitem with AM = -1 and NULL name/

How to I get my program to skip the uint32_t, then start reading the rest of the binary data into structs in C?

I have included my code below. I have it reading and printing the first line of a binary file. The rest of the file is meant to be put in a struct that contains

Pyspark create schema for maptype with different value types

I need to give the correct schema to an rdd I have, but struggling with a maptype that has different valuetypes. I guess the problem is that one specific Key ha

Returning dynamic memory inside a struct in C

Hi I have the following struct typedef struct mystruct_s { int* array; } mystruct; and I want to create a function that initializes it. I have two ways of

struct in union nested - understanding behaviour of type punning

The following code uses a structure inside a union inside a structure inside a union. #include <cstdio> union { char abcd[4]; struct {

Solidity mapping not returns an array in a struct

The Solidity's mapping not returns an array inside a struct (when call mapping_data(), the data variable is undefined). Just be able to read it from read() func

How to initialize a struct to 0 in C++

Here is a related C answer that doesn't work (as a zero initializer for a struct) in C++: Initializing a struct to 0. One of the solutions presented is this: my

Cannot Read struct with string from PLC using s7netplus c#

im trying to read this data block from Siemens S1500 PLC using s7netplus libary and my mapped code struct looks like this public struct testStruct {

How to use dynamic 2d array inside a struct array in C?

What do I want to do? I'm working on a project on dynamic matrix multiplication. I want to input from the user that on how many matrices, he/she wants to perfor

Struct padding rules in Rust

Recently when I was learning Type Layout in Rust, I saw that struct in Rust supports the #[repr(C)] directive, so I want to to see the difference between the de

How can I declare a Pointer to a struct in C?

I have learned that pointers can be declared in 3 different ways: int* a; int *b; int * c; I prefer: int* a; While declaring a pointer to a structure, is it c

How to create structs in Golang from other partial structs?

If I have a two different structs, that mostly overlap each other in regards to their property types, and I need to create one from the other, is there some mor

Getting Go to recognize when new line is added to a TOML config file

I am trying to create a simple cli tool in Go using a TOML config file. I want to be able to store frequent commands I use on the command line for other tools,

How can I initialize View Again in SwiftUI?

I’m using SwfitUI in my project and I have a NavigationView and List. I’m clicking cell after open the detail view and click navigation back button.

Interesting C macro, how is it able to take a field within a struct and return a reference to the struct?

I saw an interesting design for a doubly-linked-list inside the Pintos operating system and I don't quite understand how it was able to achieve this behavior. I

Dodging the performance hit from using `in` with a struct without making the struct readonly?

C# 7.2 added two new features: In Parameters Using in for a parameter let's us pass by reference, but then prevents us from assigning a value to it. However the

Setting a pointer to a specific array and/or struct element

Here is the scenario: I have an array, AllElements of structure ElementSet, and inside of that structure - is a set of myElement structures and also an array of

Marshaling complex C structs with c unions for C#

i am desperate to get a complex c datatype correctly marshaled for C#. I already read all the other posts regarding that topic and i am running out of ideas alt