Most voted "struct" questions
A struct or structure is a composite data type consisting of one or more variables grouped under a name.
Learn more…405 questions
Sort by count of
-
1
votes1
answer65
viewsPrintar value of a struct by pointers
I want to print the "attribute" name of a "Person" type struct, but the printf returns (null) but I declare the struct name. Follow the code below: typedef struct pessoa{ char *nome; struct pessoa…
-
1
votes1
answer275
viewsdynamic reallocation - struct array
I need to do an exercise where the code allocates the memory as needed, but I need to reallocate an array of struct, only I ended up locking in this part. My Struct is: typedef struct{ char…
-
1
votes1
answer113
viewsSyntax errors in C
I’m doing this exercise in C, but I’ve locked into this part of passing parameters with pointer. Basically the program below sums up the share of real numbers and integers. The problem is that the…
-
1
votes1
answer591
viewsStruct declaration and initialization outside the main function in C
I’m playing a little game in C that has the card structure: typedef struct { int numero; int cor; } TipoCarta; A method to put the values in the chart: void inicializaCarta(TipoCarta *carta, int…
-
1
votes1
answer470
viewsDelete a struct record using free()
I’m creating a record using struct, where I must have a menu to include, show and attend (exclude) patients. The problem is in the exclusion function that because of my lack of knowledge I do not…
-
1
votes1
answer92
viewsHow do I store data in a structure and then use it in different functions?
Guys I’m trying to schedule this work for days and I can’t get out of the corner, it’s a library system that in turn needs: a) Register, view, change and remove data from a book; b) Register, view,…
-
1
votes0
answers153
views(c) Sort Struct Matrix
Good to all! I have a little problem that I can’t solve and I seek help from the members. In my code, I read the contents of a file and save in a string for use in the code, in the main loop, I…
-
1
votes1
answer255
viewsStruct and matrix, how to relate?
I’m doing a code for a college paper and a question has arisen about how to assign values to a matrix of the type struct. struct posicao { int x; int y; }; struct posicao inimigo_val[5][15] = {…
-
1
votes1
answer339
viewsCheck if the number typed is already present on the struc
Good afternoon, I’m facing the following problem. I need to make an algorithm for registering bank accounts of 15 people with the following information: account number, name and balance. However it…
-
1
votes1
answer1151
viewsProblem with struct: "Expected Expression before"
The following problem expected Expression before 'eqp' at the line of the data function where the value is read and I could not identify the reason for this. #include <stdio.h> #include…
-
1
votes1
answer6449
views -
1
votes1
answer321
viewsStruct vector: Passage by reference in C
This code is from a simple register of people, containing code and name of the person. I am confused about the passage from the struct vector to the "insert procedure". When compiling, the program…
-
1
votes2
answers226
viewsBuild error in C++ when accessing structure in function
I’m creating a code that holds the information of three people inside one struct, but I am having a build error when I will save the age option on struct. The mistake is this: /home/arthur/Área de…
-
1
votes1
answer471
viewsArray of pointers with struct
I’m trying to assign 3 names to a string vector within a struct, and using pointers to reference the dynamically allocated struct, and then print and then reverse it into a repeat structure, but…
-
1
votes1
answer441
viewsStruct with JSON in C++
I’m having problems inflating a struct using a JSON file, in fact I don’t know how to do it, I’ve been researching about the Jsoncpp library, but I was not successful. Follow a simple example of my…
-
1
votes2
answers141
viewsPointer struct
With a view to the following structures: typedef struct celEstado *apontadorEstado; typedef struct{ char nome[30]; int populacao; int beneficiarios; int qtdCidades; float idh; apontadorEstado…
-
1
votes1
answer70
viewsObject orientation and meaningless values in c++
Hello, I’m starting programming in c++ and I decided to do a struct to learn and such... except that the compiler shows no error and at the end the program shows me a completely meaningless value,I…
-
1
votes2
answers63
viewsAverage is not being stored-C
Good night! When running the program and reporting the data Name, Nota1 and Nota2, the program is expected to create a file called "class.txt" with the student’s name, grades and average. However my…
-
1
votes1
answer94
viewsHow to create a matrix with dynamic allocation and structs
I know how to create a matrix using dynamic allocation only. However, I’m not able to create using structures. I have the following struct: struct matriz{ int** elemento; int nlinhas; int ncolunas;…
-
1
votes1
answer72
viewsHow does access to struct by pointer pointer and by a copy of the pointer work?
In push1() I passed by parameter the memory address, on push2() I passed a copy of the pointer, but I didn’t understand the difference how each one accesses the struct? struct Node { int data;…
-
1
votes3
answers170
viewsHow to query a struct array in C after you have already written on it?
Hello, I want a help I am making a program that has a menu the registered user and then consult the registration, the problem and I am not being able to consult the "database" vector of structs. The…
-
1
votes1
answer42
viewsGolang: Pass Nested Struct to Htmltemplate
Good afternoon to all! I need a help, I have two structs that are in the controller package as below: type ListValidation struct{ Id int Nameplan string Escop string Data string } type ListTests…
-
1
votes0
answers116
viewsString chained list within a struct
Hello. I’m doing a job where I need to store words in a list that must be inside a tree struct. I don’t know why the code stops inserting in the list shortly after moving to the next key/line. The…
-
0
votes2
answers2590
viewsStruct member access error passed by reference
I have the code below that has a function to define the salary = 4000, but it returns me the following error: [Error] request for Member 'salario' in Something not a Structure or Union The error…
-
0
votes2
answers249
viewsProblems with vectors and structs
I’m kind of new to C++ (because the code is basic) and I’m having a certain problem with an exercise that is necessary to store the data of 10 people (name, date of birth and height) using structs.…
-
0
votes1
answer4146
viewsStock and sales control
Hello, this progrgrama is a stock control, what he asks this in the first printf of the program, a stock and sale controller only with struct. Cases 3 and 4 are in trouble, because I can’t get…
-
0
votes2
answers1770
viewsSort a struct
Do you have any way of ordering a struct in the form: struct cidadecoord { char cidade[90]; int coordx, coordy; }cidades[N]; N is worth 30 in the case, and I would like to order x and y coordinates,…
-
0
votes2
answers1917
viewsHow to Show all elements of an array declared in a C struct?
In that 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…
-
0
votes1
answer56
viewsStream corrupting to be saved
I have the algorithm that simulates a type of registration, but when I save the file the fields, street, city and state are lost, simply disappear, and as I am saving it corrupts the file already at…
-
0
votes1
answer122
viewsProblem with Struct
I have the following error in my code: error: request for Member 'media' in 'given', wich is of non-class type 'Dadosaluno [5]' Code: #include <iostream> using namespace std; struct…
-
0
votes1
answer601
viewsHow do I define the push_back function for a c++ structure?
How do I use the function push_back in a structure? I have the arch structure: struct Arco { int i, j; Arco () {}; Arco (const Arco& obj): i(obj.i), j(obj.j) {}; Arco(int _i, int _j) : i(_i),…
-
0
votes2
answers192
viewsFile manipulation
Hello. I have a big problem to manipulate and create a C file. First I did the whole code using a struct and functions, everything worked right. I put the commands to create the file and it is also…
-
0
votes1
answer104
views -
0
votes1
answer385
viewsPass values to a struct
Good afternoon. I am in doubt whether it is possible to pass values to a C struct using JSON, Hibernate or some other known method?
-
0
votes2
answers174
viewsUse pointer on struct
I wanted to know how to access a certain element of a struct the way I’m defining it. Here’s my struct: typedef struct { char *produtos[200000]; int contador; } Produtos,*ProdutosP; Defini ProdutosP…
-
0
votes0
answers33
viewsStruct in a pack?
What happens when I put an attribute packed in a struct? What is the difference of struct that has that attribute? struct test { unsigned char field1; unsigned short field2; unsigned long field3; }…
-
0
votes1
answer426
viewsHow to change the size of a global structure vector in C?
My idea is to declare a global vector of a structure x, but I will only have the size of the vector in main. How can I declare the vector and then tell how big it is? I have an equivalent solution…
-
0
votes1
answer380
viewsrequest for Member 'attributeOuDecisao' in Something not a Structure or Union
Tree initialization error, the problem with the category variables and atributoOuDecisao. typedef struct node { int categoria; int atributoOuDecisao; struct node *prox; struct node *lista; } No; No…
-
0
votes1
answer141
viewsTwo-dimensional array size within the C-struct
Hello. I am doing a job I read a txt (the file name is passed by argv[]) and I write a graph. In the first line of the file two parameters are passed as follows: V A These parameters are integers…
-
0
votes1
answer945
viewsHow do you assign data to a struct by reading from a CSV file?
I’m having difficulty assigning read values of a file in csv format to a struct, my file has the following structure: 1;República Checa;156.9 2;Irlanda;131.1 3;Alemanha;115.8 4;Austrália;109.9…
-
0
votes1
answer99
viewspreecher array, struct in C?
how do I fill in leds and seq without needing a loop for? int main() { struct ledvalue { int seq[10]; int leds[10]; }; struct ledvalue numbers; numbers.seq={0,1,2,3,4,5,6,7,8,9};…
-
0
votes1
answer936
viewsDynamic allocation with struct
/* [Error] expected primary-expression before'*' token [Error] 'dia' was not declared in this scope [Error] 'mes' was not declared in this scope [Error] 'ano' was not declared in this scope */ This…
-
0
votes1
answer41
viewsFunction for matching points
In an exercise, I need to create a function that returns TRUE if the points are identical. For the points, a structure was implemented as follows: typedef struct //Estrutura definida para os pontos.…
-
0
votes1
answer397
viewserror: invalid use of Undefined type 'struct Fila'
I’m implementing a queue to control the threads created, in C. So as the thread is not the first in line she waits to be finished. example: // // Enquanto não é primeira da fila // while(idd !=…
-
0
votes1
answer536
viewsProgram in c presenting output, strange different from the value of variables
I’m having a problem running a program on and c that when I compile it and run it shows me a value that is not set in my variable I’m thinking it’s some bug with the ide or something related to the…
-
0
votes2
answers257
viewsHow could I enter the structs in a list?
#include "stdafx.h" #include <iostream> using namespace std; struct FICHA_INSCRICAO { char nome[50]; char cpf[10]; char logradouro[100]; char…
-
0
votes1
answer90
viewsStacks with sequential allocation
I’m having problems implementing the code of a stack using vectors: typedef struct pilha pilha; struct pilha { int *v; int topo; int tam_max; }; void Inicializar_Pilha (pilha pi, int tam_max) {…
-
0
votes2
answers427
viewsFree() in struct with char array
I have the struct struct data { int code; char name[50]; char feature[30]; }; typedef struct data Data; and the function: void free_data(Data *data) { if (data != NULL) free(data); } But the free()…
-
0
votes1
answer113
viewsHow to turn into a tiny value of a struct?
The next function should turn variables into lowercase and then compare them. I’ve tried converting before, but also bugged. Arithmetic use of pointers together with variables of a struct. Pointer…
-
0
votes1
answer65
viewsProblem with Struct Research
In my code, I can enter and delete normally, but in the searches it does not print, what could be the problem? I thought it would work the way I did. I’m doing the 'if' correctly? struct fichacarro…