Skip to main content
The 2024 Developer Survey results are live! See the results

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).

1 vote
1 answer
22 views

Can't put values together into struct that is initiated by pointer and malloc [duplicate]

Just a simple struct called person, inside I need to store name and age. I'm trying to dynamically allocate memory for my struct. Without using pointer: #include <stdio.h> #include <stdlib.h&...
cutelittlebunny's user avatar
1 vote
1 answer
21 views

Get values from a struct in an array in ColdFusion

I have an array of a struct that I need to access values like this: every new array, it should just add comma, I tried looping over an array and then struct, but trying to see if there is any easy way ...
user2675939's user avatar
0 votes
0 answers
54 views

Get templated struct without knowing initial template arguments

I am looking for a way to get a specified templated struct from the custom Node classes I am building without having to static_cast or dynamic_cast when I get the pointers. What ways can I use to ...
JemmaFromJupiter's user avatar
1 vote
1 answer
68 views

In structs, why is initializing to 0 not allowed but initializing to 1 is valid code

#include <stdio.h> struct temp{ unsigned int zero_bit : 1; unsigned int first_bit : 1; }; // struct temp_1{ // unsigned int zero_bit : 0; // unsigned int ...
WorkerBee's user avatar
-3 votes
0 answers
48 views

Trying to call a struct member function from another struct member function [duplicate]

I am trying to write a 6502 emulator, and am a bit of a noob with C++ (I normally deal with C), but I was wondering how to call a member function to a struct from another member function of a struct (...
Sentinel19's user avatar
0 votes
1 answer
16 views

Struct and Pointers: Please help me understand this line of code

Please help me understand what does the last line does: int PCKT_LEN = 8192; char buffer[PCKT_LEN]; struct iphdr *ip = (struct iphdr *) buffer; struct udphdr *udp = (struct udphdr *) (buffer + ...
X-Maki's user avatar
  • 41
0 votes
1 answer
28 views

What is the maximum number of entries a array can in a Spark column can hold?

I've created a struct with the data of some columns combined. Large numbers of these structs now occur for my unique identifier values. I want to combine these structs into an array using collect_list....
M.S.Visser's user avatar
-1 votes
0 answers
47 views

Picked structs in rust

Is it possible to have a picked struct in such a way that the type checker doesn't have a problem with it? Coming from TypeScript: // Considering a main object type containing all fields: interface ...
meclondrej's user avatar
1 vote
0 answers
27 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
148 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
70 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
111 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,337
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
126 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

15 30 50 per page
1
2 3 4 5
2044