Questions tagged as 'struct'

1
answer

How to allocate a member of a struct in C?

I would like to know if it is possible to allocate a atributo of a struct , follow my struct example: struct MinhaStructExemplo { int * atributo_quantidade; /*Atributo que eu gostaria de alocar na memoria*/ }; For the...
asked by 27.11.2015 / 00:35
1
answer

Performance differences between structs and classes

I know the difference of structs and classes is that structs has its public members by default, and that structs belong to C (but nothing prevents from using in C ++). In practice when creating an object for classes or a...
asked by 20.12.2017 / 12:09
2
answers

Pointer to struct

I was studying pointers to struct , and I saw that there are two ways to use it. can be: (*ponteiro).variavel Or: ponteiro->variavel According to what I read, when we put *ponteiro.variavel , because of the order of prec...
asked by 19.10.2018 / 18:41
1
answer

Strange values in output when running newly compiled application

When I compile and run this code in Linux , it shows a strange result. I think it's rubbish from memory. What is happening to him to show this result, and how can I resolve it? Command lines to compile code gcc -c aluno.c gcc -c test.c gcc...
asked by 04.11.2016 / 22:54
1
answer

How do I save an undefined string in a structure?

#include <stdio.h> #include <stdlib.h> #include <string.h> struct Ecoponto{ int codigo; int contentores[3]; char cidade[20]; char *rua; int nporta; }; int main(int argc, char** argv) { struct Ecoponto ecop...
asked by 05.01.2017 / 21:14
2
answers

What does "re:" and "im:" mean in Rust?

I want to know what re and im mean / do let mut z = Complex { re: 0.0, im: 0,0 }; I'm learning Rust from the Programming Rust book, and this re: and im: should have already appeared before, but just now I've both...
asked by 03.12.2018 / 13:53
3
answers

In structures (struct) is it necessary to use getters and setters or only in classes (class)?

Is it necessary to use setters and getters in structures to maintain good practices or is it only necessary in classes?     
asked by 13.12.2017 / 23:28
3
answers

Print the data of a vector in a struct

I want to make a birthday date registration system. The final doubt is: how do I print the anniversary: 1/12/1990, 12/2/1977, 09/13/1999 and 19/04/1987. They would be the examples of the printing of the dates, but I get several numbers that have...
asked by 14.11.2014 / 14:22
1
answer

Compensates to store the value of a struct member in local variable?

I see several programmers doing this. Instead of accessing the member of a struct directly, it copies the value to a local variable to the function and uses this variable. Is there performance gain in this? Does it matter if the struct...
asked by 09.02.2017 / 13:34
1
answer

What is the correct way to declare a struct in C?

Also how to rename struct data types? I have doubt about this because of a Windows Manager that I use has the following code: typedef struct exem exem; struct exem { tiposdedado variavel; };     
asked by 29.10.2016 / 13:52