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
-
3
votes1
answer96
viewsError in the calculation of values of a vector
I’m stuck in this part of my job in case two of college, the exit gets all jumbled up, for example: The profit will be -1,#$%#!@ #define vetor 40 struct Produto{ char codigo[10]; char…
-
3
votes1
answer294
viewsC socket for Linux (how to pass a struct?)
I have a client/server application and need to transfer a struct to the server, but this way is not working: typedef struct{ int pontos; int vidas; int flagReiniciar; int flagAcabar; int…
-
3
votes1
answer8777
viewsHow to connect one struct to the other?
I started in C programming recently and I have a question about structs, I wonder if it is possible to connect two structs to simulate a relationship between tables, for example struct categoria:…
-
3
votes2
answers597
views -
3
votes1
answer66
viewsAssign/Print values to void * in a structure
#include <stdio.h> typedef struct elem{ void * d; }Elem; main(){ Elem *p; Elem e; double pi = 3.14; e.d = π p->d = π printf("%f\n",p->d); printf("%f\n",e.d); } When I do…
-
3
votes1
answer107
views -
3
votes1
answer9288
viewsStore data in STRUCT and print data on screen - 3 people
Can anyone tell me what I’m doing wrong? I need to store the data of 3 people on struct and then print. This error is appearing: request for Member ːname' in Something not a Structure or Union|…
-
3
votes3
answers1104
viewsChange of vector size in a structure
I have the following structure: struct Implicantes{ int posicao; char binario[5]; bool dontcare; bool tick; struct Implicantes *Next; }; It is possible to change the vector size of char "binary" of…
-
3
votes1
answer61
viewsIs it possible to initialize a structure partially indicating the members?
In several languages it is possible to initialize a struct, or class, indicating which members want to put some value: var obj = new Tipo { b = 1, e = "x" }; In C we can initialize members in order:…
-
3
votes1
answer778
viewsTypedef struct with C character array not working
I’m trying to create a kind of constructive data, but I’m having problems with the strings. typedef struct { char nome[30]; int idade; } p; p x,y; x.nome = “ana”; x.idade = 20; y.nome = “caio”;…
-
3
votes1
answer793
viewsPointer from struct to struct
Hello, I had asked a previous question about this problem, however I was able to solve but not learn about the problem itself so I tried to isolate it by creating a specific code for this problem…
-
3
votes0
answers39
viewsWhat are structures for. NET?
What are structures for (struct) no . NET? What differs a class from a structure? In which cases would it be more feasible to use a structure than a class?
-
3
votes3
answers6206
viewsHow to set a Struct as NULL in C?
I’m looking to see if there’s any content on struct then wanted to initialize the variables as NULL, for if they were equal to NULL would know that they were not created. snippets: Struct: struct…
-
3
votes2
answers93
viewsHow to correctly iterate all records of a structure with multiple depth levels in Rust?
I would like to know how to iterate correctly in Rust all the results contained in a data structure so arranged: struct Node { id: i64, nodes: Vec<Node> } Where records entered in this…
-
3
votes1
answer751
viewsReturn of Struct in C
Hello, I’m trying to return a struct from a function when it’s called on main. I did the whole function and set in the end two elements which are calculated in function: int mult[100]; char**…
-
3
votes1
answer59
viewsHow to interpret this line? (struct list*)0)
while (variavel != (struct lista*)0) { ... } How to interpret (struct lista*)0)? What does that mean?
-
3
votes1
answer469
viewsChained list, union of structures
I have some difficulty in uniting two structures in the same chained list, I have never worked with generic lists or even associated in one activity two structures, I have the following structures:…
-
3
votes1
answer60
viewsIn a chained list structure, why is a pointer to the node pointer used?
When reading my teacher’s slides I was left with a question regarding this structure: struct node { char item; struct node *next; }; typedef struct node Node; typedef node *Lista; It wasn’t clear to…
-
3
votes1
answer52
viewsWhat does this point in the structure code mean?
int main(){ char buff[129]; WSADATA wsa; WSAStartup(MAKEWORD(2, 0), &wsa); struct sockaddr_in caddr; struct sockaddr_in saddr = { .sin_family = AF_INET, …
-
3
votes1
answer3131
views -
3
votes1
answer171
viewsHow to do mathematical operations with a struct?
I have the following structure: public struct vetor { public float X, Y; public vetor(float X, float Y) { this.X = X; this.Y = Y; } } And this code: Vars.vetor _visao; Vars.vetor _recoil; //Os 2…
-
3
votes2
answers59
viewsHow to change the way a class/structure is printed?
I have the following structure: struct cores { int r, g, b; public cores(int r, int g, int b) { this.r = r; this.g = g; this.b = b; } } If I had a new structure printed, it would look like this:…
-
3
votes1
answer568
viewsHow to create binary tree with iterative algorithm?
I’m making a program that allocates a dictionary in memory to check for misspelled words in text files. The function below converts dictionary words into integers and stores them in tree structures.…
-
3
votes1
answer119
viewsProgram has memory junk 2 in C
That’s the question of the program: Make a program, using the function below, that displays the highest salary of each department of a company and how many employees earn the department’s highest…
-
3
votes1
answer1363
viewsPass data from a struct within the function
I’m doing a college job where I have a separate function that gets two values (WEIGHT and HEIGHT) and returns the BMI. I have tbm a struct called STUDENT where is stored weight and height and a…
-
3
votes1
answer511
viewsError printing struct member: request for Member in Something not a Structure or Union
I have the following struct: typedef struct{ int Numerador ; int Denominador ; } TNumeroRacional ; In this function I ask the user to insert 2 numerators and denominators to form 2 rational numbers.…
-
3
votes1
answer111
viewsHow to allocate in contiguous memory a structure that contains 1 vector with user defined size?
I was wondering how to answer this issue and I came to the conclusion that I would need a data structure with: the size of a set a previously reported size vector It would be something like the…
-
3
votes1
answer575
viewsError Unknown type name 'typeTelephone'
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> typedef struct{ int id; char nome[20]; tipoTelefone telefone; }tipoCliente; typedef struct{ int…
-
3
votes2
answers626
viewsWays to initialize struct’s
I know these two ways to boot struct's. #include <stdio.h> typedef struct { char s[10]; int a, b; double x; } TIPO; int main(){ TIPO v1[10]={"foo", 5, 13, 4.3, "bar", 0, 0, 2.3}; TIPO…
-
3
votes1
answer61
viewsDo vectors and structures always have continuous addresses?
Why vectors and structures are continuous in memory? I believe that it is not just coincidence. #include <stdio.h> int main(void){ char s[10]; for (int i=0; i<10; i++) printf("%d=%p.\n", i,…
-
2
votes2
answers3403
viewsCPF data in a C Struct
Hello. I’m having a problem reading data from a CPF. I tried using int, long int or even a char vector[12]. With char I can keep the CPF’s that contain '0' at the beginning, and with int or long int…
-
2
votes2
answers306
viewsDoubt in Struct + Pointer in C
Considering the code below, I wonder why the second printf of the Lealuno procedure does not print correctly? #define MAX 3 typedef struct aluno{ int matricula; float notas[2]; } Aluno ; int t=1;…
-
2
votes1
answer205
viewsConvert struct with nested struct to record
I have a little "hindrance" in a project I’m working on. We received a DLL written in C, in order to communicate with readers of this company. In attachment came an example written in Borland C++ 6,…
-
2
votes1
answer1393
viewsVector struct and pointers
I have to pick up data (name and phone) of some people in a struct, then store them in an array, all this for a function/procedure. At the time of printing comes out some strange characters. I’m…
-
2
votes1
answer1040
viewsPackage strings using struct
I’m doing a basic exercise using the module struct, and I came across a problem: To pack a string, we should inform in the method struct.pack() the number of characters it has, right? But what if…
-
2
votes1
answer135
viewsFaster way to add an item to an array, using a structure
Structure turma Public id_turma As Integer Public nome_turma As String End Structure Structure Disciplina Public id_disciplinas As Integer Public nome_disciplina As Integer End Structure Public…
-
2
votes1
answer246
viewsProblem to assign more than one value to variable
#include <stdio.h> int main(){ int d; int e; int peca1; printf("digite um lado da peca: "); scanf("%i", &d); printf("digite outro lado da peca: "); scanf("%i", &e); peca1 = d , e…
-
2
votes2
answers324
viewsHow to declare a component of a static struct in the function? C
In the file . h: struct conectores { int entrada[n]; int busca[n]; } conect; struct connectors conect; void cadastra_entrada(FILE *fp, int cont, struct conectores conect, int entrada[n]); Function:…
-
2
votes1
answer174
viewsCommit Structure
I wonder if you have how to change a commit structure, in the case before it is made a predetermined structure, example: GIT_AUTHOR_NAME = '$name(Previamente registrado)' GIT_AUTHOR_DATE =…
-
2
votes1
answer1889
viewsBreak line when typing entries
I have a vector of structs with 10 people and I want my registration function to receive only one person at a time. In the terminal, the register of the first person is made correctly but then I get…
-
2
votes1
answer215
viewsDefine an array and the type of a function in C
Hello, I am developing a C language boot project, namely the creation of a Multimedia Management System that will have to be able to manage a database of discographic articles such as Cds, Dvds and…
-
2
votes3
answers582
viewsHow to dynamically increase struct size?
How to increase the size of struct when the current size is reached? #define TAM_MAX 50; typedef struct{ char nome[TAM_NOME]; /* nao pode ser vazio*/ char sobrenome[TAM_SOBRENOME]; char…
-
2
votes1
answer631
viewsList of structs
I would like to know the advantage of using a list in this way. typedef struct Pessoas { char nome[20]; int idade; struct Pessoas *prox; }pessoas; typedef struct Funcionario { pessoas *pessoa;…
-
2
votes1
answer1133
viewsReference struct inside another in C
I need there to be a reference to struct inside the other. But in the example below as the struct TAnimal does not yet exist, her reference in struct error player. How to get around this situation?…
-
2
votes3
answers2408
views -
2
votes2
answers896
viewsStruct or Classes, huh?
I made the code using structure, I wanted to know if with classes it would be more efficient. I’m doing it in C++ Builder. The idea of the code and the following: create a list of problems, where…
-
2
votes2
answers463
viewsStruct definition in C
Hello, my teacher has made the following definition of some structs for a list code in data structure, but unfortunately I cannot understand the definition of each struct itself. typedef struct{ int…
-
2
votes1
answer1098
viewsWhy is this error? - invalid application of ?sizeof' to incomplete type
When I try to compile(gcc test.c) it generates the following error: The code: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct aluno Aluno; int main() {…
-
2
votes1
answer110
viewsPrinting a vector... Differences between C++ and C... Where did I go wrong?
I’m having problems printing vector structs in C, in C++ it worked... First I will show the version in C with problems (in the execution because compiles without errors) CACHE cache =…
-
2
votes1
answer323
viewsHow to copy an array of struct to an equal one?
I have 2 arrays made of a struct: struct events { string Kind; int Time; int DurVal; int Chan; }; events e1[100] events e2[100]; How can I make a full copy of the array e1 for e2 in a single…