Questions tagged as 'struct'

2
answers

What is the difference between the data types enum, struct and union in C?

I'm reading the GNU C manual and I'm in the Data Types section and I notice a certain similarity between% types of%,% with%, and% with%. Is the syntax the same, or is there something that differs between them? In which cases should I use which...
asked by 27.06.2016 / 19:59
1
answer

Store data in STRUCT and print data on screen - 3 people

Can anyone tell me what I'm doing wrong? I need to store the data of 3 people in struct and then print it. This error is appearing:    request for member 'name' in something not a structure or union   request for member 'age' in someth...
asked by 17.09.2015 / 17:26
1
answer

Dynamic Pointer Allocation in C ++

I need to create a protection routine in the removal function. Why did you make an error removing the last item? The function: // Remover o primeiro cliente void cadRemover(){ lista=ini; // Volta ao início aux = lista; // Copia o 1º p...
asked by 09.08.2014 / 14:12
1
answer

Program has memory garbage 2 in C

This is the program question: Make a program, using the function below, that displays the highest salary of each department in a company and how many employees earn the highest salary in the department. For each department, the program should...
asked by 15.05.2018 / 23:52
1
answer

Return from Struct in C

Hello, I am trying to return a struct from a function when it is called in main. I have done the whole function and define in the end two elements that are calculated in the function: int mult[100]; char** elemfim = (char**)malloc(100 * sizeof...
asked by 13.12.2017 / 12:29
1
answer

Is it possible to initialize a structure partially indicating the members?

In several languages it is possible to initialize a struct , or class, indicating which members want to put some value: var obj = new Tipo { b = 1, e = "x" }; In C we can initialize the members in order: Tipo obj = { 0, 1, 2, 'c', "...
asked by 17.01.2017 / 11:34
1
answer

Linked list, union of structures

I'm having a hard time joining two structures in the same linked list, I've never worked with generic lists or even linked two structures together in one activity, I have the following structures: struct Patio { char iden_patio; int ca...
asked by 30.03.2017 / 03:29
1
answer

Pointer to struct for struct

Hello, I had asked a previous question about this problem, but I managed to solve it but did not learn about the problem itself so I tried to isolate it by creating a specific code for this problem and I would like someone to teach me what is hap...
asked by 27.05.2016 / 06:39
2
answers

How do I pass an array of structure pointers to a function?

#include <stdio.h> #include <stdlib.h> #define NUM_NOTAS 5 #define TAM_NOME 20 struct Aluno{ char nome[TAM_NOME]; int numero; int notas[NUM_NOTAS]; }; void preenche(struct Aluno* lista[], int tam){ int i; int j; for(i=0;i<...
asked by 04.01.2017 / 16:31
1
answer

How to connect a struct in the other?

I started programming in C recently and I have a question about structs , I would like to know if it is possible to connect two structs to simulate a relationship between tables, for example struct categoria : struct categor...
asked by 11.12.2015 / 15:56