Questions tagged as 'struct'

2
answers

Average calculation problem between int and float

I have a problem with a mean calculation. I have a struct with 3 fields. The ones I'm wanting to average are quantity of products and unit value. I need to average between all products and their prices. However, when I have unit values with 0...
asked by 11.05.2014 / 00:17
2
answers

Struct with pointer and allocation

I can not use fscanf in a structure, I have already allocated structures. #include <stdlib.h> #include <stdio.h> #include <string.h> struct Cliente { int numero; char *nome; }; struct Filme { int numero;...
asked by 27.04.2014 / 20:30
1
answer

Struct Vector: Pass by reference in C

This code is a simple register of people, containing code and the person's name. I am confused as to passing the struct vector to the "insert" procedure. When compiling, the program stops working. In the compiler I get the following error: "P...
asked by 30.10.2018 / 19:38
1
answer

Struct and matrix, how to relate?

I'm making a code for a college job and a question has arisen about how to assign values to an array of type struct . struct posicao { int x; int y; }; struct posicao inimigo_val[5][15] = { {{0,-1},{0,-1},{0,-1},{0,-1},{0,-1},{0,-1},{0,...
asked by 10.07.2018 / 19:13
1
answer

Check if the number entered is already present in struc

Good afternoon, I'm facing the following problem. I need to make an algorithm for registering 15 people with the following information: account number, name and balance. However it is necessary to check if the account number has already been ent...
asked by 30.07.2018 / 17:30
1
answer

Delete a record in struct using free ()

I am creating a registry using struct , where I should have a menu to include, display and answer (exclude) patients. The problem is in the delete function that because of my lack of knowledge I do not understand what the correct way to...
asked by 17.06.2018 / 02:41
1
answer

How to access elements of a vector of a type defined by struct?

In my code, I made the following struct declaration: struct material { int idmaterial; double rho; double precokg; }; I wanted to run this function, which reads the data from a file: std::vector<material> le_material(std...
asked by 14.05.2018 / 17:19
1
answer

How do I define an element of a struct in C? [closed]

I want to make a program that uses structs to store data, but that there is already some data inserted in it, I'll give a similar example: struct registro { char nome[30], telefone[11]; int idade }dados; In case I would need...
asked by 06.06.2018 / 21:13
3
answers

Micro system of classes in C

Hello. I have a small problem that I can not resolve. What I would like to do is simply initialize a struct that receives function pointers automatically. For example: struct teste{ int x; int y; int (*soma)(int, int); }; typed...
asked by 25.05.2018 / 00:26
2
answers

Binary File Reading in C ++

Good morning. I'm trying to do a read of structs that I've inserted into a binary file, but it's giving error at the time of reading. Here is the code for the read function: void lerRegistros(char* file_name) { ifstream entrada;...
asked by 15.01.2018 / 18:40