Questions tagged as 'struct'

3
answers

Allocate memory in C for structure vector

What is the right way to allocate memory for an array vector? struct CARRO{ int id; char fabricante[MAX]; char modelo[MAX]; int ano; char cor[MAX]; int preco; }; int main(){ int qtd, i; scanf("%d", &qtd);...
asked by 27.06.2017 / 04:25
1
answer

What is the utility of the struct command in c?

I've already learned how to use the command in a code, but I still do not understand exactly what it's for. Could someone explain me, with examples if possible, its usefulness?     
asked by 24.08.2018 / 06:36
2
answers

Memory Allocation and Pointers

I'm implementing a Sudoku, but I'm having a hard time filling it out. #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <math.h> #include <stdio_ext.h> typedef struct grid_info {...
asked by 03.09.2015 / 06:11
2
answers

How do I define operator = for a struct in c ++?

I have the following structure: struct PATH { vector<ARCO_TEMPO> rota; set<int> rotaAux; float COST; int nArcosVoyage; vector<bool> VisitedNodes; vector<vector<bool>> VisitedVertices; int head_no;...
asked by 03.04.2018 / 22:29
1
answer

Why can not I access the data of this struct with the dot, only with the arrow?

I have alloted this struct by dynamic allocation and can only access the data idade via arrow and not by point wanted to know why? #include<stdio.h> #include <stdlib.h> struct pessoa { int idade; }; void alteraId...
asked by 21.12.2018 / 23:19
2
answers

Problem with Struct and Function in C

Good evening, I have a problem with the code I'm doing. I'm not sure if I'm deleting the values correctly (and replacing the next). The error is appearing in the substitution by the next and I do not know if I'm correctly passing the x, which is...
asked by 30.09.2016 / 22:52
2
answers

My struct declaration is wrong?

#include <stdio.h> #include <stdlib.h> fun1(int ptr,int data) { data.ano=1990; data.mes=5; data.dia=15; ptr->nome="Bigown"; ptr->cpf="040502016"; } int main () { typedef struct { int ano; int mes;...
asked by 04.05.2016 / 20:15
1
answer

How to sort array structures based on song rank?

The rank of the code is going in increasing order but the others do not change the positions along with the rank, how do I position the songs and styles to go along with the code? #include <stdio.h> #include <locale.h> struct musi...
asked by 08.11.2017 / 23:56
2
answers

Error translating structure code from C ++ to C #

I'm trying to read a string from a process, I found this structure on the internet: struct name { wchar_t nome[32]; }; I did it this way: struct name { public char[] nome = new char[32]; } And I'm returning the following erro...
asked by 27.11.2017 / 22:13
1
answer

Problem with float vector

I created a code for a college exercise that was running right, but I forgot that one of the variables of struct was a vector, and when I made a simple change everything changed. Virtually all functions are giving error. I do not find the...
asked by 19.06.2015 / 05:41