Questions tagged as 'struct'

1
answer

Difference between cast of structures

struct a{ int a; int b; }; struct b{ int a; int b; } int main() { struct a *p; struct b b; p = (struct a *)b; // deste modo da erro p = (struct a *)&b; ; deste modo o compilador não aponta erro; } Would you li...
asked by 31.01.2016 / 22:09
3
answers

Struct and chained list

I created a person-type structure and I want to use it in a linked list, but the following errors appear:    'No' has no member named 'data', 'No' has no member named 'prox' and unknow type name 'p'. The program did not even run, can anyo...
asked by 25.06.2014 / 20:58
2
answers

Can I return a struct by initializing it inside a return in ANSI C?

Good morning, I'd like to know if I can do something like this ... typedef struct Result { int low, high, sum; } Result; Result teste(){ return {.low = 0, .high = 100, .sum = 150}; } I know this would not be a right way, but is there...
asked by 06.09.2014 / 15:36
2
answers

How to iterate correctly all the records of a structure with multiple depth levels in Rust?

I would like to know how to iterate correctly in Rust all the results contained in a data structure arranged like this: struct Node { id: i64, nodes: Vec<Node> } Where records entered in this structure have several levels of d...
asked by 13.12.2017 / 06:57
1
answer

Typing a pointer to struct

I was suggested to build a linked list using the following struct as a node: typedef struct node *link; struct node{ int item; link next; }; As I did not understand what the pointer operator along with this typedef I...
asked by 03.10.2015 / 16:14
1
answer

Error in calculating values of a vector

I'm stopped at this part of my job in college case 2, the output gets all mixed up, for example:    Profit will be -1,#$%#!@ #define vetor 40 struct Produto{ char codigo[10]; char descricao[100]; float precoCompra;...
asked by 28.08.2014 / 21:29
1
answer

Why does this work? pointer = (struct a *) & b;

struct a { int a; int b; }; struct b { int a; int b; }; struct a *ponteiroa; struct b b; b.b = 20; ponteiroa = &b; //Isto não dá certo ponteiroa = (struct a *)&b; Why does this (struct a *)&b work? Why c...
asked by 19.09.2018 / 23:59
2
answers

How to make a struct in C #?

How to make a structure in C # where you create a type? For example, in C ++ we use: struct teste { int a; char c[30]; };     
asked by 03.01.2016 / 02:41
2
answers

CPF data in a C struct

Hello. I'm having a problem reading data from a CPF. I tried using int, long int or even a char vector [12]. With char I keep the CPF's containing '0' at startup, and with int or long int it does not return correct due to size. I need to sort wi...
asked by 21.06.2014 / 18:37
1
answer

How to copy an array from struct to another array?

I have 2 arrays made from a struct : struct events { string Kind; int Time; int DurVal; int Chan; }; events e1[100] events e2[100]; How can I make a full copy of array e1 to e2 in a simple command?     
asked by 16.08.2018 / 02:38