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
answer156
viewsHow to pass, by reference, a vector of structures to a function?
I’m having great difficulty understanding the reference passage of a structure vector. No running error happening, but not sure if I am reading the file correctly there. #include <stdio.h>…
-
0
votes3
answers1105
viewsReading Struct Strings with Wrong Scanf
Good guys, I am developing a C code that performs data registration in files. However, I have a problem in the function register, which you will see below among the codes. Struct of the client:…
-
0
votes1
answer803
viewsSorted list C++ struct
I need to do a job with this struct and that contains insertion, search and exclusion by year and printing. Only that I am doubtful in the following code. I need right after insertion to be ordered.…
-
0
votes0
answers48
viewsError in C list of structures
I’m working on a list of structures code, where I have a structure called Cad that contains the registration fields, name and salary. And a list containing a field of type struct Cad that stores the…
-
0
votes2
answers32
viewsAfter typing the P Value, you are not running the printf of the second for
#define MAX 15 #define TAM 2 struct { char m[MAX]; int ano; float v; } car[TAM]; int main(void) { int i; int p; for(i=0; i<TAM;…
-
0
votes0
answers59
viewsHow do I pass the values stored in a truck so another function can modify it?
I’ve been trying to make this project run since yesterday, but I can’t manipulate the data of my struct when I move it to another function, the other function simply create other values, the goal of…
-
0
votes1
answer1497
viewsHow to edit data from a Struct using a function
I want to create an edit function that takes as a parameter the music array by reference. (using pointers) The user must choose the song number and type back the data from that vector position. I…
-
0
votes1
answer54
viewsQuicksort C - Contest. c:16:50: error: request for Member' name in Something not a Structure or Union
I’m trying to make this URI thing: Tetris His high school class decided to organize a tetris championship. After discussion about the rules, it was defined that each student would play a total of 12…
-
0
votes1
answer394
viewsdynamic matrix allocation within a struct
statement and code: Make a program that stores movies produced by various directors and: - Create and read a vector of 5 directors, each containing name (maximum 20 letters), number of movies and…
-
0
votes1
answer522
viewsAssign values to a struct array in Golang
I’m starting to learn go and need to populate the different structs with their values. I thought about creating an array of structs and trying to use a for to fill the fields but give an error of…
-
0
votes1
answer88
viewsError referencing Struct with Pointers
I’m trying to convert this below algorithm into c language but I’m having trouble calling the variable and assigning a value to p.key=1 of the struct element. Error Code: error: request for Member…
-
0
votes1
answer148
views -
0
votes1
answer156
viewsRead char matrix from a binary file
Function that writes and reads binary file: int FUNCAO_QUE_GRAVA_BIN (char filename[],int partida1,char resultado1) { typedef struct { int partida; char jogvelha[3][3]; char resultado; } velha;…
-
0
votes0
answers82
viewsSave variable to struct by pointer
I have a problem with my code that I can’t solve, I think it’s a simple detail, but so far I haven’t discovered. I need to reference a vector, which has a struct, but it is not allocating the data…
-
0
votes1
answer106
viewsCopy one binary file to another in C
Good! I am creating a car management program, and I need to first insert my cars (structs) in a binary file (draft), and then use another function to update, and pass the structs of that binary to…
-
0
votes1
answer565
viewsPassage by struct vector reference
I have to do an exercise where I get a struct and a vector following this struct with a size N of houses (which I called in the code of QTD) entered by the user. After this the program allows to…
-
0
votes1
answer559
viewsRequest for Member 'name' in Something not a Structure or Union - Error
#include <stdio.h> #define MAX_VETOR 6 const int na = 1; typedef struct { char nome[10]; char sexo[1]; } tp_pessoa; typedef struct { tp_pessoa *pessoas[MAX_VETOR]; int inicio,fim; } tp_vetor;…
-
0
votes1
answer241
viewsHelp with Struct and File Manipulation (C)
Hi, I need you to help me... I did this algorithm to register the "interviews" of employees, and whenever I want to fetch an employee, I simply put his name and all the data relating to him appear.…
-
0
votes2
answers84
viewsForm with Struct and Pointers
Guys, I made this program to receive name, address and phone of 2 people, he receives the data of the first people quietly, problems begin with the data of the second person, the name and address of…
-
0
votes1
answer169
viewsfree() in char dynamic stack does not work - C
Hello, I’m having trouble trying to release dynamically allocated memory. For small string there is time that works, but for large string the program tops. There’s a time when a 3-character or…
-
0
votes1
answer152
viewsProblem in returning Struct in C
I’m making a simple program in C that takes name, enrollment and two student grades but when returning the value typed struct in the function Show it does not return anything #include…
-
0
votes1
answer25
viewsFunction does not recognize the structure created in main
I made a system and created a two Structs to store data of people of a hotel, but when trying to organize them in order of weight the system gives the following error: line 100 error: incompatible…
-
0
votes1
answer182
viewsPrint and receive Vector Struct values in a function
I looked in several places about it but I couldn’t find any correct answer, I wanted to know the correct method of filling a structure vector passed by reference to one function and then printing in…
-
0
votes2
answers249
viewsProblems with CRUD in C (DELETE method)
In the delete function, the user will inform an AR that he wants to delete, when the AR exists in the memory he deletes, that part of the code works... The problem is when it does not find in memory…
-
0
votes0
answers66
viewsIn C -> Multiple Struct Passages as Parameter
Good to all! I am studying about double chained lists, arose the need to pass one struct into another struct, into another. I already managed to make one, however, instead of using a book struct, I…
-
0
votes1
answer41
viewsVector in struct does not work
Good night! I’m trying to store some variables in a struct with a .dat. My goal is to take each line of this file and store it in a vector position of the struct. The Qtd and the track are working,…
-
0
votes1
answer403
viewsPass data from one array to another
How can I pass some data from one vector to another? I’m doing an exercise and I need to take several data from several students at struct and place in a vector. Then I need to check if they were…
-
0
votes3
answers246
viewsRead and print struct values
I have an algorithm that reads name, sector and number of 10 employees, I’m trying to read in a function but I’m not succeeding, when I try to print only out numbers. This is a piece of content that…
-
0
votes1
answer154
viewsDo you need to allocate memory when you have struct inside another struct?
I want to save and recover data from a struct, but this struct has other struct inside it, I don’t know if I did it correctly, I don’t know if I should use typedef or just struct. I don’t know if I…
-
0
votes0
answers53
viewsDifficulty with dynamic struct allocation
The question is : implement a type of Tbaralho dice to represent a pile of cards. Your data type should store the cards in the deck and the amount of cards present. Consider that the maximum size of…
-
0
votes1
answer204
viewsHello, I’m trying to do a data structures exercise in c, but there’s an error and I can’t find it. Follow the statement and the code
4. Write in C a system for enrollment and visualization of students. /// To store all students, implement a dynamic vector of pointers for structs, with a size of 100 records #include<stdio.h>…
-
0
votes0
answers41
viewsBug in AVL tree implementation
I’m trying to implement an AVL tree, but when I call the Inserts function in the main and step some value(int) happens something strange. The first time the if (of the Inserts function) is…
-
0
votes2
answers75
viewsHow to print the two vector values in the pointer struct?
I made a code with struct Pessoa to save more than one note and print using pointer. My question: how do I print in function listar() the two notes I recorded in the function main()? I’m doing it…
-
0
votes0
answers103
viewsC Pointer Vector Search
Consider a type that represents an employee of a company, defined by the following structure: typedef struct funcionario Funcionario; struct funcionario { char nome[81]; // Nome do funcionário float…
-
0
votes1
answer45
viewsHow to insert data into a member vector of a struct?
I’m trying to build a structure composed of members that are no more than strings. The 4th member is a string array, since it needs to store more than one piece of information. Once done I declare I…
-
0
votes1
answer51
viewsStack algorithm problem in C (Struct and function do not "recognize")
Hello, I’m starting in the study of data structures and one of the algorithms passed is for data increment in a vector as in a stack (ie, the last incremented is the first to come out) I am in the…
-
0
votes1
answer51
viewsStruct in C print nothing
Hello, I am doing a program for college and have to add books in a struct and then print your data, I created a menu of options and used ifs as a switch, one of ifs is used to add books to struct…
-
0
votes1
answer20
viewsProblem alternating fgets and scanf_s
I have a problem that the user has to enter the name and age of 5 people, and have to print on the screen the name of the younger person. I made the following code #include <stdio.h> #include…
-
0
votes0
answers26
viewsProblems in a stack whose positions should be selected? ( Warning: implicit declaration and Warning: Pointer from integer)
Hello, today I bring here a question related to data structures that surely can add in the understanding of all envovilido. It is a matter of pile manipulation where through the act of traversing…
-
0
votes0
answers923
viewsError: "The expression must be a modifiable lvalue"
Hello! I’m learning C, and I’m trying to make a simple program, which consists of a "Stack of Books" in which I need to Store the Book Title, Author and Book Code, using structs and Stacks of Data.…
-
0
votes1
answer142
viewsstruct function parameters
I am making a code that calculates the sum and subtraction of complex numbers, however, I cannot find the error to compile. #include<stdio.h> #include<math.h> typedef struct NI { float…
-
0
votes1
answer261
viewsHow to Read and Print String with c++ space?
I even managed to make my program read the String (name of a person) with space in C++. However, when printing only returns the first name of the person as in my program below. //Write a program…
-
0
votes1
answer34
viewsAllocate Attribute Memory in Structure
I need to allocate more memory of the note attribute of the Student structure: #include <stdio.h> #include <stdlib.h> struct Aluno { int matricula; int nota; }; void cadastraNotas(struct…
-
0
votes0
answers30
views"Dereferencing NULL Pointer" error in a chained list structure
My code deals with a simple endadeada list (then I will implement the pointer to turn double). But in the line strcpy_s(new_element->musica_name, musica_name); He keeps giving an…
-
0
votes0
answers42
viewsDuplicate the last line of the file . txt c++
#include <fstream> #include <vector> using namespace std; struct Produto { string nomeProduto,quantidade,marca,preco; }; void carregaProdutos(vector<Produto> &R) { ifstream…
-
0
votes1
answer293
viewsSave data from a txt file to an entire struct or manipulate struct. C
I have a txt file that follows the template below. I want to save the balance as int, but with fgets I can’t get it. I’m wanting to save as int, because after the data is taken the program sorts…
-
0
votes0
answers33
viewsWhat is the best way to save multiple data types of a struct {} in a text file?
I need to create a program that registers a user and stores their respective data in a text file. It happens to be various data (Name, CPF, Phone, Address, email, etc.). Then I created a struct full…
-
0
votes1
answer35
viewsError accessing a struct
I created a function to read how many hours the employee worked in the week, however, I have problems effectively saving in the memory of struct. Calling the function:…
-
0
votes0
answers39
viewsProblem increasing array size within struct dynamically
Problem I am doing a test program that receives names of students and their grades, with the number of students being able to increase indefinitely, for this I used a struct with two arrays inside…
-
0
votes1
answer62
viewsI can’t copy a string array to a string array in a struct
I’ve been racking my brain for hours, and I can’t seem to fix it. I want to copy a new string and place it in the first position of a string array in a struct. However, when I try to copy the new…