Questions tagged as 'struct'

1
answer

How to change the size of a global vector of structures in C?

My idea is to declare a global vector of a x-structure, but I will only have the size of the vector in main. How can I declare the vector and then tell it the size of it? I have an equivalent solution in Java, but not in C.     
asked by 20.08.2016 / 22:34
1
answer

How does C ++ padding work?

In several responses here in StackOverflow I have noticed users commenting on padding in data structures. struct { int a; char b; float d; } What is this padding (filler) that exists between the fields of a struct...
asked by 13.02.2015 / 13:29
1
answer

How to pass a pointer inside a struct per function parameter?

The situation is as follows: I have a struct with a field that is a pointer pointer, however I want to pass as a parameter in a function only the pointer pointed to, that is, the most internal pointer of that field in the struct: In code i...
asked by 25.10.2015 / 12:53
2
answers

How to show all elements of an array declared in a struct in C?

In this code: #include <stdio.h> #include <stdlib.h> struct cadastro { char nome[50]; int idade; char rua[50]; int numero; }; int main() { struct cadastro c[4]; //Array[4] de estruturas for(int i=0; i<4; i++) {...
asked by 18.05.2015 / 05:27
2
answers

After entering the Value of P, you are not running the printf of the second for

#define MAX 15 #define TAM 2 struct { char m[MAX]; int ano; float v; } car[TAM]; int main(void) { int i; int p; for(i=0; i<TAM; i++) { printf("Determine a Marca e Modelo do Carro %d: ", i+1); gets(...
asked by 17.06.2018 / 05:48
2
answers

I can not register a person's name in my calendar

I am making a very simple agenda, the numbers I have managed to castrate however the names of the people I could not. My code #include <stdio.h> #include <malloc.h> #define MAX 50 typedef struct { int numero[MAX]; char nom...
asked by 29.06.2018 / 18:57
1
answer

Saving stream to a file

I'm having the following problem, when saving the struct, to position 1, ends up losing street, city and state value. I do not understand why this happens if in the following positions it allocates in a normal way, and the code to do such thin...
asked by 26.11.2014 / 14:42
1
answer

Read the elements of a struct in another function

I need to access struct data in my CalcN function, how should I proceed? int main(){ int calcn(); struct user1{ string Nome; int Dnx; int Nxhu; }; struct user1 x; x.Dnx = 4; x.Nxhu = 3; int Resultad...
asked by 25.11.2014 / 23:28
1
answer

Pointer function for pointer

I have the following function NOTE: In this function is only the first case, not to get too large. Since the error occurs at the first insertion. int insertAVL_TreeR(struct AVL_TreeNode **node, void *elem, int *h) { if (!node) {//...
asked by 25.02.2016 / 02:25
1
answer

Doubt Nesting Structs

I need to make a product registration program and include these products in a shopping cart and end the sale. Before I had already done a program that registered the products, which contained only the struct Product: So: struct Produto{...
asked by 04.12.2016 / 17:26