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
votes0
answers30
viewsHow to correct fgets() that for the program
My code has two structs. One is inside the other. when I fill out the registration it gets the people[qtdPeople]. name however when it will receive people[qtdPeople]. home->street it to. I wonder…
-
0
votes0
answers19
viewsC-struct occupies more memory space than the sequence of its members
No 1° example a struct occupies 16bytes: #include <Studio.h> int main() { struct horario{ int hora; int minuto; int *h; }; struct horario agora; int tamanho = sizeof(agora); printf("%d…
-
0
votes0
answers45
viewsComplicator does not give error, but the program does not start
I’m learning data structure with the C language, but I realized that I should study a little more struct and pointers, in one of the exercises that I was given is to create struct with day, month…
-
0
votes0
answers21
viewsC Structures insert made but cannot read
I have a struct typedef struct { int id; char nome[50]; int tipoUser; float vencimentos; int id_clinica; } Utilizador; into which I enter values using the following code: void…
-
0
votes1
answer39
viewsProblems to edit items within the struct
I have the following struct: typedef struct { int id; char nome[50]; int tipoUser; float vencimentos; int id_clinica; } Utilizador; I enter in the same values from the following functions : void…
-
0
votes2
answers135
viewsPassing a struct as parameter
Good afternoon! Can anyone help me? I’m having doubts in this exercise... I’m not getting through parameter to struct for another function. NOTE: I am starting now... it is advisable to keep the…
-
0
votes1
answer38
viewsWhat is wrong with my program for not giving the output of the structure object?
#include <stdio.h> #include <stdlib.h> #include <locale.h> #include <string.h> #define MAX 30 #define N_DISCIPLINAS 5 #define N_CHARDISCIPLINAS 30 /* run this program using…
-
0
votes1
answer152
viewsHow to write read information from a . csv file to a C Language struct
I’m needing to open a . csv file and save your information in a struct array I need the way out: Code - Region - UF - Date But you’re being: Code - Region - UFDATA - DATA I would like to know what…
-
0
votes0
answers27
viewsPointer matrix with no type and variable size in C
I am creating a game for my college work and need to read a txt file to build a level (phase) of the game. The txt example can be accessed here: https://pastebin.com/f778Ucxa. The dash represents an…
-
0
votes1
answer33
viewsVector exchange of chars with problem
I’m trying to sort this struct vector that has random int values and a char vector also with random values. But I ran into a problem. The idea is to sort them from the random numbers and the letters…
-
0
votes0
answers37
viewsI’m having trouble storing a value in the C struct
When it comes to printing, they are somehow superimposed. I have no idea what it might be. The FOR is strange because it is necessary that Tsala data[FLOOR][ROOM][TURN] be this way and in that…
-
0
votes1
answer23
viewsProblem with spaces and structs in C
I’m starting to learn about C structs, but I’m having trouble trying to store data in user-filled empty strings. When the user inserts a product description at the first time of the repeat loop, the…
-
0
votes1
answer49
viewsAdd nodes to the chained list using loop
I did not find any similar question, in case you have, please indicate and I delete the post. How to create a chained list so I can use a for loop to put the nodes in the list. I’m using two…
-
0
votes1
answer44
viewsHow to write a function that returns appropriate values of a date (day, month and year) so that these are assigned to struct-type variables?
I wanted to develop a function responsible for analyzing the format of the date inserted, however the appropriate values would have to be returned to another function responsible for registering…
-
0
votes1
answer65
viewsProblem assigning values to a struct in C
Hello, I know how to program in other languages but I’m a beginner in C and I’m burning my brains out doing a job for the college that asks to store information of 10 vehicles in an array of…
-
0
votes1
answer38
views -
-1
votes1
answer490
viewsRead the elements of a struct in another function
I need to access data from struct in my job CalcN, how should I proceed? int main(){ int calcn(); struct user1{ string Nome; int Dnx; int Nxhu; }; struct user1 x; x.Dnx = 4; x.Nxhu = 3; int…
-
-1
votes1
answer142
viewsSaving stream in a file
I have the following problem, saving the struct, the position 1, ends up losing the value of street, city and state. I do not understand why this happens if in the following positions it allocates…
-
-1
votes1
answer438
viewsHow to pass a pointer inside a struct per function parameter?
The situation is as follows: I have a struct with a field that is a pointer pointer, however I want to pass as parameter in a function only the pointer pointed, that is, the innermost pointer of…
-
-1
votes1
answer317
viewsFunction with pointer to pointer
I have the following function NOTE: In this function is only the first case, so it doesn’t get too big. Since the error occurs right at the first insertion. int insertAVL_TreeR(struct AVL_TreeNode…
-
-1
votes1
answer96
viewsDoubt Nesting of Structs
I need to make a program that registers product and include these products in a shopping cart and finalize the sale. Before I had done a program that registered the products, which contained only…
-
-1
votes1
answer49
viewsHow do I associate a car with a driver in that code that I made
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> #include <locale.h> typedef struct Motorista{ int driver_id; // id do motorista int idade;…
-
-1
votes1
answer805
viewsCopy string to struct
While trying to copy String nome into String in Struct novo->nome the program stops working if I comment on the function strcpy(novo->nome,nome); the code is executed normally. //Função de…
-
-1
votes2
answers57
viewsStructs not fed
Dear Programmers(s) in C, good night, I ask for help for the following case: I want to feed an array of structs to each interaction in a line of a file, the problem is that, although I can read the…
-
-1
votes1
answer34
viewsI’m not getting these steps ! I wanted help
(b) Find the student with the highest score of the first test. (c) Find the student with the highest overall average. (d) Find the student with the lowest overall average. #define MAX 50 struct {…
-
-1
votes2
answers71
viewsI can’t seem to register a person’s name in my calendar
I’m making a very simple schedule, the numbers I managed to castrate but the names of the people I couldn’t get. My code #include <stdio.h> #include <malloc.h> #define MAX 50 typedef…
-
-1
votes1
answer83
viewspassage by struct reference does not work (Dynamic queue C)
I’m trying to implement a dynamic Fila. When I start the program (start and end = NULL), and then place to queue a value (queue function) the pointer "end" receives the new queue item, but the…
-
-1
votes1
answer126
viewsHow can I store token values in an array?
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <assert.h> typedef struct{ int id; char nome[20]; char telefone[9]; }tipoCliente;…
-
-1
votes1
answer63
viewsStruct member print print something strange
I’m doing a job that uses struct it’s all right but when it comes to listing the last one comes out with a strange character. My code is like this struct livro_cadastro{ int codigo; char obra[30];…
-
-1
votes1
answer71
viewsCreate resulting strcut in C
I’m doing an exercise where the user inserts the data of a vehicle (brand, year, price) in a struct. After that, the user enters a value. To struct resulting shall show only the data of the vehicles…
-
-1
votes1
answer58
viewsProblem with DYNAMIC ALLOCATION with char pointer in structs
I have the following problem: I must create a program that will register an N number of students and the maximum size of each student’s name is M. I must use the following structure: struct Aluno{…
-
-1
votes2
answers205
viewsHow to store data from a struct in a vector (c++)
I’m having trouble storing information inside a vector. I need to store information like a user’s name, password and account number, so I’m using a struct typedef struct { int conta; string nome;…
-
-1
votes2
answers38
viewsPointer+Struct (DOUBT)
Good afternoon guys, I’m learning to use pointers in struct's... so I tried to do a record exercise of nome and id very simple with a vector size for only 3 entries. I can’t find the error of my…
-
-1
votes1
answer31
viewsError request for Member 'salario' in Something not a Structure or Union
Guys, I need help with the sum of variables in a struct. the program does not compile and displays this error [Error] request for Member 'salario' in Something not a Structure or Union. The…
-
-1
votes1
answer30
viewsFamily struct problem in c
Hello I’m having trouble in this question: "Write a program that reads and stores in an array the data of 30 persons. These data are the name of the person, his age, and the full names of the father…
-
-1
votes1
answer50
viewsSomeone could help me work struct with vectors and function, I’m not sure when to pass the data
typedef struct { int cod, num_hab; char sigla_esta[5], estado[30], cidade[30]; }Cidade; main() { //Variaveis Cidade cidades[max]; Estado estados[max]; Pais paises[max]; int op, i, posl, aux; int cc…
-
-1
votes1
answer29
viewsI’m not able to read strings with space and store them
#include <stdlib.h> struct dado_cidade { char cidade[20]; float taxa_2009; float taxa_2015; float indice_percent; } cidades[27]; int main () { FILE *dados; dados = fopen("dados_tabela.txt",…
-
-1
votes1
answer24
viewsHow to pass string to struct within the function
Hi, I have to do a CRUD in C, but I have a problem, I have to pass 3 strings to a function but I have no idea how to do, I’ve tried everything... #include <stdio.h> #include <stdlib.h>…
-
-1
votes1
answer36
viewsProblem to link two structs in C
The program is about a bank, I need two structs (one of client and one of accounts), the account holder has to be linked with some client. But in the Add_account function, I am not able to make this…
-
-1
votes1
answer23
views -
-1
votes1
answer20
viewsAssign a float in main() to a struct inside another struct
I’m doing an exercise and I can’t understand what I’m missing in this final part. Basically I need to do a struct to register an employee, and within that struct use another struct with the value of…
-
-2
votes1
answer4125
viewsCalculate distance between two points in C++ using struct
I’m having a hard time printing the result, but before that it’s not realized because it’s a new type created by struct He doesn’t know because he asks double follows the code #include…
-
-2
votes1
answer34
viewsHow to verify that the limit of a vector has not been exceeded?
Good afternoon, gentlemen! I’m doing a college paper that asks me to create an agenda. I did most of the code, but I’m not able to see the light so that when the user tries to register a person in…
-
-2
votes1
answer107
viewsGet size of a two-dimensional matrix
I have a dynamically allocated two-dimensional char matrix, as I do to get its size? would use sizeof(client); for example, I instated a client struct, Client **client; then in the code I’ll…
-
-2
votes2
answers55
viewsExercise to sequence numbers with Struct
I’m doing an exercise to sequence numbers using a struct, but what’s happening is that in my for the variable i is being incremented in a very strange way, in the second passage of scanf, its value…
-
-2
votes1
answer54
views -
-2
votes1
answer79
viewsError in Structure Memory Allocation
PROGRAM The program highlights memory as more students or more grades are added, but in certain tests depending on the number of students or grades it takes "dirty" values from memory and plays for…
-
-2
votes1
answer44
viewsDatabase using vector and struct in c
People I need to make a program where I save client data and accounts, I’m trying to save the data of the struct in a vector (it was requested this way) but I’m not getting out of place, I don’t…
-
-2
votes1
answer26
viewschar array comparison returns false even for char[] equal - C
I am a beginner in C, I am doing a college activity and trying to compare a data obtained via scanf with a data saved in a registry array that I believe but even entering the same value, always…
-
-3
votes1
answer43
viewswant to create a struct of variable size and error program
i am trying to create a struct of variable size but always q do it in the second run of the loop the program hangs #include <stdio.h> #include <stdlib.h> struct produto{ int…