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
30,649
questions
-2
votes
0
answers
18
views
Linter Warning: struct field tag `json:email_addresses` not compatible with reflect.StructTag.Get: bad syntax for struct tag value [closed]
I have the following struct defined:
type User struct {
gorm.Model
FirstName string `json:"first_name" gorm:"type:varchar(32); not null" binding:"required&...
1
vote
1
answer
27
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&...
1
vote
1
answer
40
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
...
0
votes
1
answer
60
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 ...
1
vote
1
answer
69
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 ...
-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 (...
0
votes
1
answer
17
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 + ...
0
votes
1
answer
31
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....
-1
votes
1
answer
51
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 ...
1
vote
0
answers
28
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) ...
1
vote
1
answer
149
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 "...
0
votes
1
answer
71
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 ...
-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 ...
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 ...
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) ...