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
-
0
votes1
answer232
viewsfread and structure memory allocation
I have the following structure: typedef struct registro {//52 bytes char codigo[4]; char descricao[31]; char unidade[3]; int quantidade; float valor; char status; }registro; It must store the values…
-
0
votes1
answer247
viewsWhen I try to make a.bin file it gives multiple definition error in all functions
In the Linux i use the following command lines to run all files: gcc -c aluno.c // gera o arquivo objeto com extensão .o de mesmo nome gcc -c teste.c gcc -o prog.bin teste.o aluno.o //para criar o…
-
0
votes0
answers287
viewsInsert priority calls into a queue using nested struct
Talk people!!! All beauty? I made another code that is showing the result and I can also de-rank and insert the values removed from this main row into a secondary structure according to the…
-
0
votes1
answer80
viewsWhen a 'cloned' struct is changed it changes all the others
I have the following statements: #define SCALE 4 #define PADDING 1.1 #define CUBES 27 #define CUBE_VERTICES 8 #define CUBE_FACES 6 #define FACE_VERTICES 4 typedef struct { float angle; float x;…
-
0
votes2
answers104
viewsHow to pass structure data to a text file?
I have this structure: struct televisao { int id_guit; int precodia; int preco; int estado; char nome[20]; }; I wanted to ask the user to insert data from this structure and store it in a . txt…
-
0
votes1
answer2016
viewsHow to make an appointment in C language?
Good evening, I’m doing a little project of writing binary files in a txt and then reading these files. But I have to read the file or list them all. How could I do a search for the necessary file?…
-
0
votes1
answer52
viewsStruct ! Error on line 47 at the moment it compiles, Follow the program in c
#define MAX 50 struct{ int ra; char nome[MAX]; float prova; }aluno[5]; int main(){ struct aluno; int i; int j; printf("Determine o Nome do…
-
0
votes2
answers1127
views -
0
votes1
answer68
viewsMy struct type is not recognized within my class
Guys, I’m implementing a stack with C++ pointers and have the following code for now: template <class T> struct Node { T item; Node *prox; }; class Pilha { private: int tamanho; Node *topo;…
-
0
votes1
answer60
viewsError when passing a structure by reference in C
I’m learning C. However, I had a problem getting through a structure to a function. I cannot understand which is the error. I will be grateful if someone helps me. Me sorry for the bad…
-
0
votes1
answer162
viewsRuntime error in C
Well, it’s compiling everything ok, however, when I print out the elements of the entire tab matrix[8][8], which is a member of the checksum structure, the compiler, in a way is assigning numbers to…
-
0
votes1
answer41
viewsProblems accessing struct members
I have to do some functions with these structs, but since Agenda has a contact struct array and in each contact has another data struct, how do I access the fields? Do I have to work each struct…
-
0
votes1
answer117
viewsDoubts in code C data structure
Good afternoon, good I’m here to see if anyone knows why my code is printing a junk memory, when run it shows what I want but it prints a junk memory, if anyone knows why thank you #include…
-
0
votes1
answer191
viewspassword confirmation in c
I need to register N people in my program with only two information: name and password. Then the user enters a name, if this name is not registered the program displays a message of no registration…
-
0
votes0
answers267
viewsPass struct type vector as parameter of a function in C
I need to create a function that is in a file. h that generates random numbers n (defined by the user and passed by parameter in the function), and populate set b with the generated values.…
-
0
votes0
answers55
views -
0
votes1
answer41
viewsI created a function to receive a structure, but it always returns 0, can anyone help me?
Structure: typedef struct entrada{ int M; long int Nmax; double a0, a1, a2, a3, a4, a5; double A, B, e1, e2; }valor; Function: double FuncaoDada(struct entrada valor, double x) { double resultado;…
-
0
votes1
answer348
viewsReading txt file in C and data interpretation
I need to read txt files in C and interpret the data from inside the files. The files contain parts in TEXT and others in DECIMAL/INTEGER numbers. What I need to do is read the whole file and pass…
-
0
votes1
answer393
viewsDouble Chained List Removal Doubt (C/ Ordered Insertion)
In a C++ class the teacher had proposed an activity where I had to do a program in the format of a double-chained list with ordered insertion. However, I have a problem on the Removal part. By…
-
0
votes0
answers92
viewsHow can I read a CSV file with different line types?
I am trying to read a CSV file that has different lines. I am using fgets and Strtok to store in a list. the problem is that being different lines do not know how to stop and move to the next.…
-
0
votes2
answers272
viewsWhat are the benefits of using struct?
As that type variables struct are stored in memory, for example: struct livro{ char autor[10]; float preco; }; //como essas variaveis fica alocado na memória? struct livro livro1;…
-
0
votes1
answer59
viewsI’m having trouble printing a variable in my program
I’m doing a program that simulates a bank, in function criarpessoafisica I’m trying to get the algorithm to check that Cpf is already registered, but it’s not working ! For some reason he printed…
-
0
votes0
answers17
viewsStruct error reading second name
Good afternoon, I’m doing a struct that stores name and age,the first step of the loop,but when it goes to read the second name it jumps,. #include <stdio.h> #include <stdlib.h>…
-
0
votes1
answer114
viewsmatrix product using struct
I used struct to store number of rows and columns of the matrix. I make the product of two matrices and the product of a matrix with a vector, but the output is always 0. I do not know how to change…
-
0
votes0
answers188
viewsstruct that stores the number of rows and columns of the matrix and of a vector
I used a struct to store the number of rows (m) and columns (n) of the matrix and another to store the number of columns of the vector (n). I make the product of two matrices in function prod() and…
-
0
votes1
answer99
viewsHow to make variable receive function argument value?
Next: I have a code for how to create a point structure on an Rxr plan. In this case, I would like to access the "x" value of a point. Follow the codes: File point. h: //Arquivo Ponto.h typedef…
-
0
votes1
answer73
viewsHow do I pass a list of parameters to a precedent?
I want to pass N parameters of N types to a dynamic process. How can I do it? Example: struct = (Here the structure will be mounted with several parameters) struct.id = 123 struct.name='Marisa'…
-
0
votes2
answers42
viewsWhy not print the contact variable[0]->a?
Pointers still confuse me mostly in situations like this. The idea is simple. I’m trying to create a pointer vector like struct. But I must be using some misconception of pointers because the…
-
0
votes2
answers99
viewsI’m having trouble reading a string inside a function
Good evening, I would like to know methods to read a string in C(Version C99), I have tried a lot, and does not work, below, the defective code. Obs: The error that reports is that just after…
-
0
votes2
answers59
viewserror: expected Expression before struct
Why are you making a mistake? Why? Error = |21|error: expected Expression before 'Simple list'| #define MAX 25 typedef struct Rota Rota; typedef struct ListaRota ListaRota; typedef struct…
-
0
votes1
answer51
viewsWhy use a pointer to struct instead of the struct itself in this case?
Why, in the struct GERENTE and CLIENTE, I have to use a pointer to the struct PESSOA and not the struct PESSOA typedef struct{ char* nome; int cpf; } PESSOA; typedef struct{ PESSOA* pessoa; int…
-
0
votes2
answers194
viewsMatrix vector of records
In the classroom, students were asked to replicate a scheme designed by the teacher. In this scheme he made a vector, within each position he made a matrix and within each position of the matrix he…
-
0
votes1
answer43
viewsChained list returning empty outside function
I’m trying to read data from a file .obj and insert into a chained list, I have a function to read and within it I call the insert function. When I call the function of printing the list inside the…
-
0
votes2
answers768
viewsCommand "goto" creating infinite loop in "for" loop
I want to simulate a school database that collects name, math and physics grades and averages both for 5 students (defined in a string of struct). Any grade above 10 would be allowed, without any…
-
0
votes1
answer518
viewsFiles For Structs/C Pointers
I have this little program and I’m able to save, and upload from the file to struct(not perfectly). The error is as follows: after loading the file to struct, if in the function I load the printf it…
-
0
votes1
answer44
viewsPrinting the shortest distances
The exercise asks me to print the smallest routes between n cities, whereas the latter is the same city as the starting point. First, I need to read an input file like the following: 5 1 10 4 4 5 1…
-
0
votes2
answers83
viewsAccessing variables from a struct
I am studying C and I am doubtful in the difference of the following lines: (*depois).agora = 20 and *depois.agora = 20; From what I understand the point . has priority and the compiler would try to…
-
0
votes1
answer32
viewsSegmentation float when starting the function for the second time
I created a program in c++ to manipulate matrices,and I divided the source code into 2 files, one with functions and the other with implementation, all functions work correctly, but when starting…
-
0
votes2
answers47
viewsStruct array accepting more than defined, what’s wrong?
In the code I created a array of the kind Pessoa containing only 2, but when it starts to iterate on the for loop and accesses index 2 and 3 the condigo continues without generating error at compile…
-
0
votes2
answers466
viewsIs it wrong to mix struct with class in C++?
I have the following class: #ifndef PESSOA_H_INCLUDED #define PESSOA_H_INCLUDED #include <string> struct aniver{ int dia; int mes; int ano; }; class Pessoa{ private: std::string nome;…
-
0
votes1
answer302
viewsCall a function based on the struct passed in the reference?
How Do I call the menu function by passing more than one struct per reference according to the validation in the validation function ? sorry I’m starting now and decided to do this little exercise…
-
0
votes2
answers1600
viewsVector size in C
I am new to the C language and am getting problems to determine the size of vectors of the struct type. Example. I have a category type structure with three types of variables 1 int and 2 char.…
-
0
votes1
answer288
viewsPass values by reference C
I have to make a program with options menu that allows me to read a student’s information, write their name and phone after entering their student number, and determine how many students are older…
-
0
votes1
answer213
viewsCould C-structs have builders?
I have the following structure within a program: struct STR00034ST{ char C_O010XC14B, C_O020XC14B; short S_0010XI15C; float F_0010XI1D; STR00034ST (char _C_O010XC14B, char _C_O020XC14B, short…
-
0
votes1
answer70
viewspass a struct using extern C on a . dll c++
I have a function that comes from a . lib that returns me a struct tabela GSTV(vector<double> inpA, vector<double> inpB); this struct is defined as follows:: struct tabela {…
-
0
votes1
answer68
viewsAccessing the allocation causes program to stop working
I’m having a problem accessing a subscriber struct typedef struct Inscrito { char nome[50]; float cadastro; float nota; }; Inscrito *inscritos = NULL; it is as a global variable and every time I…
-
0
votes1
answer161
views -
0
votes0
answers674
viewsHow to create QUEUE by passing STRUCT
I am trying to create a code in which I will insert 10 candidate names in a queue using a C structure. But I don’t have much knowledge in C data structure. I did it this way: #define TAM 5 #include…
-
0
votes0
answers134
viewsHow to detect the end of a file reading in a while loop in C++
In my code, there’s the struct: struct material { int idmaterial; double rho; double precokg; }; And the reading function of a data vector of type "material", from a file:…
-
0
votes1
answer63
viewshow to pass two structs per function
I have two structs, one for the student data and one for a hash table, where the collisions of the matricules go. To know if there was a precise collision of these two structs ,but dev says that…