Skip to main content

Questions tagged [struct]

A keyword in various programming languages whose syntax is similar to or derived from C (C++, C#, Swift, Go, Rust, etc.). Use a specific programming language tag to tag questions involving use of a `struct` as syntax and semantics can be language dependent. Keyword defines or declares a data type composed of other data types. Each member of a struct has its own area of memory (as opposed to a `union` whose members share a single area of memory).

struct
1 vote
0 answers
21 views

Issue converting struct to parquet using xitongsys/parquet-go ( runtime error: invalid memory address or nil pointer dereference )

The timestamp in my struct is causing the following error: runtime error: invalid memory address or nil pointer dereference The struct is: type MyTs struct { time.Time } func (myts *MyTs) ...
user1898662's user avatar
1 vote
1 answer
132 views

Can't understand this C syntax. Designated initialization of an array of structs?

Trying to learn the nuances of C, though I was doing well until I found this: #define SOKOL_IMPL #define SOKOL_GLES3 #include "sokol_gfx.h" #include "sokol_log.h" #include "...
Matheus de Moraes Peixoto's user avatar
0 votes
1 answer
69 views

C code for solving a 15-puzzle gives a segmentation fault when it tries to show the paths for each update to the puzzle

I have a code that is supposed to show the paths in solving a 15-puzzle after showing the initial state and goal state. However, while it does show the initial state and goal state, it gives a ...
Sebastian Llaurador's user avatar
-3 votes
0 answers
91 views

Why doesnt my program execute whenever i declare a struct? [closed]

I am working on the project euler problem 81: https://projecteuler.net/problem=81 I am trying to read a text file containing a matrix of numbers, load this into a two dimensional array, then declare a ...
timmy george's user avatar
1 vote
1 answer
105 views

Why is it considered okay to use structs to represent MMIO registers in embedded system firmware, but not bit fields?

In embedded system firmware, it's common to represent multiple memory-mapped registers of a peripheral using a struct, under the assumption that compiler's code generation will follow a particular ...
比尔盖子's user avatar
  • 3,317
0 votes
0 answers
27 views

Rust lifetimes in structs [duplicate]

Why is it not working? struct Test<'s>(&'s mut i32); impl<'n, 's: 'n> Test<'s> { fn new(i: &'s mut i32) -> Self { Self(i) } fn cast(&'s mut self) ...
Danila's user avatar
  • 73
1 vote
4 answers
121 views

Using free on nested structs makes program crash

I was recently exploring ll the oop features of C, when i came to this issue. I want to create a game engine with C, so i use nested structs to organize ewerything. But when freeing the memory, the ...
TheTrueJerome's user avatar
0 votes
0 answers
21 views

unpack requires a buffer of X bytes

field_names = [] for i in range(obj["fields_cnt"]): print(i) name_len = struct.unpack('H', f.read(2))[0] print(type(name_len)) print(...
inkmilkyy's user avatar
2 votes
2 answers
71 views

Struct loses value in UnitTest

I came across a strange behavior and would like some clarification what's happening here. I did create a simple immutable struct public readonly struct MatchingPair : IEquatable<MatchingPair> { ...
Iaman Swtrse's user avatar
-7 votes
0 answers
53 views

How To Access An Item In A Struct Which Is In An Array [closed]

I am making a tower defense game and used structs in an array and want to access an item in the structs. I don't want to use a 2d array as that can't show up in a unity editor. I tried tutorials and ...
Simon Y's user avatar
0 votes
0 answers
32 views

STM32 HAL_TIM_PWM_PulseFinishedCallback not being called. Suspect that problem is related to use of struct or union pointers

I'm writing a Neopixel driver for STM32 based on the example provided here. In summary, the pixels aren't lighting correctly. My latest attempt had the first row of 8 pixels light up green before it ...
Anonymaton's user avatar
-2 votes
1 answer
57 views

Binding/Pass-By-Reference for Array from Struct to Struct

I have one struct, struct DropletsView: View {} which has the following array: @State private var savedQuotes: [Quote] = [] (Quote is defined elsewhere, as a custom type for my app). I would like to ...
Daggerpov's user avatar
  • 162
0 votes
2 answers
69 views

Go Pass Func to Struct like fields, Error "too few values in struct literal of type Test"

type Test struct { a int b int } func f(a, b int) (int, int) { return a, b } k := Test{(f(5, 6))} // Error but type Test struct { a int } func f(a int) int { return a } k := ...
Сергей Ковальчук's user avatar
-3 votes
2 answers
58 views

How can i select one of declared structure and make alias? [closed]

enum class Color { RED, BLACK }; enum class TreeModel { AVL, RED_BACK, SPLAY } struct BasicNode { BasicNode* left; BasicNode* right; BasicNode* parent; }; struct SplayNode : BasicNode { ...
vansergh's user avatar
0 votes
1 answer
55 views

Invalid initializer error with anonymous structs

I have this code here: Void() aba () { } #define std_Dynamic_Array(T) struct{Int32() count; Int32() capacity; T* memory; } Void() no_body_func (Int32() b); Int32() test_func (Int32()*** a) { } Int32() ...
kamkow1's user avatar
  • 499

15 30 50 per page
1
2 3 4 5
2043