Most voted "allocation" questions
Allocation refers to interpreted languages such as C and C++, which dynamic memory allocation is part of data management and security.
Learn more…152 questions
Sort by count of
-
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
votes2
answers211
viewsCreate chained list with realloc()
I need to implement a simply chained list that does not have a next indication, that is, it should function as an array, accessing nearby positions in memory. I’m using the realloc() command to try…
-
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
answer79
viewsAllocate space to a double vector vector vector
I’m trying to allocate space in memory for a double vector vector vector. I know that for a vector vector I can do vector<vector<double>> Vetor(51, vector<double>(47, 1)) And this…
-
0
votes2
answers86
viewsProblem with dynamic allocation of bidimencional matrices in C
I need to make a product of matrices in which the user must enter the dimensions and terms of the matrices, but the program simply stops working. Follows the code: #include<stdio.h>…
-
0
votes1
answer40
views`System.Nullreferenceexception` in C
Running the following code shows the error System.NullReferenceException in function call SubString #include <stdio.h> #include <stdlib.h> #include <string.h> // // Implementado o…
-
0
votes2
answers85
viewsSegmentation Fault with malloc()
In one part of my program I need to create a vector full of zeros the size of the user’s interval: scanf("%ld %ld", &n1, &n2); int *vetor; vetor = malloc((n2 - n1 + 1) * sizeof(long int));…
-
0
votes1
answer56
viewsSIGSEGV error in using a pointer
I have the following problem: I am creating a pointer and allocating memory in it, passing its reference to function, but when I read it in the function happens the error reported in the title.…
-
0
votes1
answer132
viewsHow to allocate memory space?
Make a program to allocate memory space for 10 integers and ask the user to enter 10 values. Later, print your respective memory address and content. What I have to change in my program to make it…
-
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
answer877
viewsRead text file picking float numbers and playing in matrix
I have a text file for example with: v 1.000000 -1.000000 -1.000000 v 1.000000 -1.000000 1.000000 v -1.000000 -1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -0.999999 v…
-
0
votes1
answer101
viewsBizarre error with dynamic allocation
I wrote this simple program: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char *nome; nome = (char *)malloc(10 * sizeof(char)); if(nome == NULL) {…
-
0
votes2
answers179
viewsIs there realloc() in C++?
The realloc() is unique to C? Would it have any function that would be equal in C++?
-
0
votes0
answers30
viewsWhy does this appear when compiling? "Segmentation fault (core dumped)"
#include <stdlib.h> int funcao(int **piParametro) { …
-
0
votes0
answers534
viewsStructure and Pointers in C: Binary Tree
Hello, I’m trying to create a mathematical expression tree with the following logic: my expression is a string, and I have 4 character options: ( : When finding this character, my code should create…
-
0
votes1
answer1626
viewsdouble free or corruption(out) - Dynamic Allocation in C
In the discipline of Data Structure in college, as an exercise, the implementation of an algorithm that manages the transposed matrix of a given dynamically allocated matrix was passed. I made the…
-
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
answer110
viewsI need an explanation why the C code gives a Segmentation fault error
I started my dynamic allocation studies but I’m not able to make a simple example, I couldn’t find the problem. #include <stdio.h> #include <stdlib.h> #define SUCESSO 1 #define FALHA -1…
-
0
votes3
answers176
viewsDynamic allocation with a void function
I made a simple code using dynamic allocation. Just ask for the vector size, to insert data and print them at the end I can make dynamic allocation with int, returning the vet, but as I’m learning,…
-
0
votes2
answers208
viewsIs it always good to de-locate the memory before a "sudden" output of the program with the Exit function call?
When I was beginning to learn pointers and dynamic memory allocation in C, I was told that all memory allocated in the program is out of focus when it is finished. Ex: #include <stdlib.h> int…
-
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
answer178
viewsRow function in C
I created the next queue: typedef struct No { int pos; char cpf[12]; char nome[40]; struct No *prox; } No; typedef struct No * p_no; typedef struct{ p_no ini, fim; } Fila; typedef Fila * p_fila; And…
-
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
votes2
answers2087
viewsProblem with perfect number in C
I’m having trouble showing if the number is perfect, when I put in 6, it says it’s not perfect, and I can only use pointer and dynamic allocation. Someone would know how to help me? #include…
-
0
votes3
answers335
viewsError when De-locating Matrix - double free or corruption C
Hello, I’m running a program to rotate a matrix, which after allocating executes the rotation function, and then displaces the data. The problem is when I try to dislocate, it’s returning me double…
-
0
votes0
answers173
viewsError Segmentation fault(core dumped) in C
When trying to calculate which prime can make a division of rest 0 with the number 600851475143 I came across the error segementation fault(core dumped) (although I used the sieve of Eratosthenes…
-
0
votes0
answers26
viewsIncreasing the capacity of an int - C
When trying to calculate which prime can do a 0 rest split with the number 600851475143, I get the error Segmentation fault with the following script: int count_1 = 0, count_2 = 0, soma = 0, maior =…
-
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
votes2
answers155
viewsVariable receiving trash
Considering this simple password validator in C: #include <stdio.h> #include <string.h> int main(void) { char buff[5]; int pass = 0; printf("\n Entre com a senha : \n"); gets(buff); if…
-
0
votes1
answer31
viewsPseudo-Object Orientation in C and Dynamic Allocation
I’m trying to make a minefield in c using ncurses. h and when I’m going to do the vector of "bomb objects" Linux says it can’t find the memory space in which the values of the bombs are: PS: no I…
-
0
votes0
answers35
viewsNumber of cases in an age range (allocation problems)
The user will provide multiple (first given number) triple entries with the first number being 0, the second number being the number of disease cases at a given age (third number) or the first…
-
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
votes1
answer36
viewsHow to return a pointer to a dynamically allocated String, declared within a function?
//Função de inversão de String. #include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 30 char* invertStr(char *source) { int size = strlen(source); char *inverted…
-
0
votes0
answers50
viewsExecution error in c
I have a problem with the following code: #include <stdio.h> #include <stdlib.h> #include <string.h> char **tabela_hash; int valorTotal=0; void inicializarTabela(int *pm) { for…
-
0
votes2
answers91
viewsfree() does not work in Dynamic Stack code
The dynamic stack works normally, but when I try to use the free() method to de-locate the memory of the removed elements and reboot the structure, the compiler does not return as expected.…
-
0
votes2
answers77
viewsMemory allocation with malloc()
Doubt 1: The pont should reserve a memory block for 1 integer which was requested on malloc(), but he reserves 32 bytes or a memory block for 8 integers. 'Cause he does it? Doubt 2: If I make one…
-
0
votes1
answer56
viewsHow do I pick up two values obtained in a function through pointers?
I am building a program, whose enunciation is to make the user provide 20 numbers and these are analyzed as pairs or odd. In this case, the intention is to create a vector A that takes 20 integers…
-
0
votes0
answers36
viewsPointer pointer in C
Come on, guys, I’m trying to understand the pointer-pointer behavior, but I can’t figure it out. Well, I already have an idea that the pointer points the memory address of something, to another…
-
-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
answer76
viewsDoubts about pointers and dynamic allocation
I’m having difficulty doing this activity. If possible, give me tips and solutions to improve the code. And explain to me why the compiler can run the program but when arriving at the end of the…
-
-1
votes1
answer60
viewsError in vector size
I’m having a little problem here in my code, well "everything" works normal except when I type that the struct vector size will be 2, program simply stops working. #include <stdio.h> #include…
-
-1
votes1
answer163
viewsHow to use a function to fill all positions of the dynamically allocated vector?
Good afternoon guys, I’m seeing for the first time the C language and I’m not making progress on a job. First you are asked to create a function int receive Operator() This function will request the…
-
-1
votes1
answer47
viewsDynamic allocation in wrong scope
I dynamically allotted a vector of structures with qtdeFuncionarios positions within a if, but now I need to use it within another conditional structure and the compiler accuses scope problem. How…
-
-1
votes1
answer79
viewsRead string pointer in C
This is the question: 4. Make a program that receives from the user the size of a string and call a function to dynamically allocate this string. Then the user must inform the contents of this…
-
-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
votes1
answer49
viewsHow to access, within a function, the member of a dynamically allocated structure?
I have the following code in C: #include <stdio.h> #include <stdlib.h> struct pessoa{ char nome[11]; int idade; } void cadastra_pessoa(char novo_nome[11], int nova_idade, struct pessoa…
-
-2
votes2
answers556
viewsReceive multiple strings in the same row in C
I have the following code that gets the keyboard input and prints on the screen what was typed. #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char…
-
-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
answer52
viewserror out of Bounds in doctor memory
I am having an error out of Bounds on doctor memory, and at the time of printing the files. There is something wrong with this code? #include<stdio.h> #include<stdlib.h> typedef struct{…