struct Questions
2
Solved
I have a C struct defined as:
struct my_c_s {
u_char *ptr;
unsigned flag_a:1;
unsigned flag_b:1;
int some_num;
}
How would flag_a and flag_b be represented?
#[repr(C)]
pub struct my_rust_s ...
Ian asked 21/7, 2017 at 4:48
8
Solved
I have a question concerning type constructors within a Value type. This question was inspired by something that Jeffrey Richter wrote in CLR via C# 3rd ed, he says (on page 195 - chapter 8) that y...
Disharmonious asked 14/7, 2010 at 12:33
5
Solved
I am trying to copy a struct of type Big to type Small without explicitly creating a new struct of type Small with the same fields.
I have tried searching for other similar problems such as this a...
6
Is there any way to prevent the default constructor of a struct to be called?
I have several structs in my project and some of them I can not let the default constructor to be called at any circum...
Precursor asked 13/4, 2016 at 16:44
11
Solved
Previously, when I needed to store a number of related variables, I'd create a class.
function Item(id, speaker, country) {
this.id = id;
this.speaker = speaker;
this.country = country;
}
var my...
Partida asked 2/2, 2009 at 6:25
4
Solved
Generally, in order to initialize a struct in c, we could only specify part of the fields. Like below:
static struct fuse_operations hello_oper = {
.getattr = hello_getattr,
.readdir = hello_rea...
Mouflon asked 25/8, 2012 at 13:7
4
Solved
I like value semantics in Swift but I am worried about the performance of mutating functions. Suppose we have the following struct:
struct Point {
var x = 0.0
mutating func add(_ t:Double){
x +=...
Elea asked 23/2, 2017 at 16:5
7
Solved
I have two structures, with values that should compute a pondered average, like this simplified version:
typedef struct
{
int v_move, v_read, v_suck, v_flush, v_nop, v_call;
} values;
typedef st...
3
Solved
I am struggling with deserializing a integer into a string struct field.
The struct field is a string and is expected to be assignable from users of my library. That's why I want it to be a string,...
Knitted asked 30/8, 2017 at 19:37
5
Solved
I am curious to know, Is it possible to use array of bit fields? Like:
struct st
{
unsigned int i[5]: 4;
};
Axiomatic asked 29/1, 2017 at 6:56
1
I would like to define a struct, Env which optionally contains a (mutable) reference to another Env, called it's parent. In all applications it can be easily shown that the parent will outlive the ...
18
Solved
How can I print (to the console) the Id, Title, Name, etc. of this struct in Golang?
type Project struct {
Id int64 `json:"project_id"`
Title string `json:"title"`
Name strin...
2
Solved
Is it possible to require that a struct have a particular field as part of a trait? I am doing some web automation in Rust with the thirtyfour_sync crate. I want to write some traits with default i...
Potamic asked 29/6, 2021 at 2:31
17
Solved
I want to initialize a struct element, split in declaration and initialization. This is what I have:
typedef struct MY_TYPE {
bool flag;
short int value;
double stuff;
} MY_TYPE;
void function...
Antidepressant asked 1/12, 2008 at 13:13
8
Solved
So I've got a collection of structs (it's actually a WCF datacontract but I'm presuming this has no bearing here).
List<OptionalExtra> OptionalExtras;
OptionalExtra is a struct.
public pa...
9
Solved
I have a slice of structs.
type Config struct {
Key string
Value string
}
// I form a slice of the above struct
var myconfig []Config
// unmarshal a response body into the above slice
if err ...
4
Solved
I defined my struct as:
struct taxPayer{
char name[25];
long int socialSecNum;
float taxRate;
float income;
float taxes;
};
My main function contains:
taxPayer citizen1, citizen2;
citize...
12
Solved
how can I convert a string ipAddress (struct in_addr) and vice versa?
and how do I turn in unsigned long ipAddress?
thanks
Syncopate asked 16/3, 2011 at 16:2
14
Solved
5
Solved
I have a struct type with a *int64 field.
type SomeType struct {
SomeField *int64
}
At some point in my code, I want to declare a literal of this (say, when I know said value should be 0, or po...
5
Solved
What is the recommended way to declare a struct that contains an array, and then create a zero-initialized instance?
Here is the struct:
#[derive(Default)]
struct Histogram {
sum: u32,
bins: [...
Rajiv asked 21/11, 2014 at 13:49
7
Anybody think there are advantages to using a class or struct to pass arguments ?
Like instead of
f(int,float,string)
Have
f(Args)
Where Args is struct with int,float,string members.
Advant...
7
Solved
Consider a function which returns two values. We can write:
// Using out:
string MyFunction(string input, out int count)
// Using Tuple class:
Tuple<string, int> MyFunction(string inp...
Baca asked 17/6, 2011 at 6:1
5
Solved
I have four integers {a, b, c, d} that can have the following range of values:
a - {0 or 1} (1 bit)
b - {0 or 1} (1 bit)
c - {0, 1, 2, ..., 7} (3 bits)
d - {0, 1, 2, ..., 7} (3 bits)
at first,...
6
Solved
I have the function below which accepts a bool pointer. I'm wondering if there is any notation which allows me to set the value of the is field to true in the struct literal; basically without to d...
© 2022 - 2024 — McMap. All rights reserved.