Realloc Questions
Ad
How to dynamically increase size of any structure objects during runtime?
I am a bit of a beginner in c language. i was trying out a task of dynamically reallocating memory as the input comes through(although for this
Why does free() cause an error in my code when it's there, but everything runs well when it is not there?
My program takes an arbitrary number of words at runtime and stores them in a dynamically-sized array of words. currently, my program runs
Is it safe to call realloc() on the pointer you pass into function itself?
Note: i am not 100% confident with memory allocation and how it works, but i understand it for the most part. when i see
What am I doing wrong with malloc and realloc of array of struct?
I'm trying to build in c an array of structures without defining the length of the maximum size of the array. #include
How to fix realloc expected declaration specifiers or ‘...’ before ‘sizeof’ error?
I get the following error below after calling realloc void* realloc(sizeof(char)100); the error:
My realloc function is doing realloc only once when working with a dynamic array of structs
I have a function leerarch() that reads a file with information of students and returns a pointer to a dynamic array of structs
Malloc/realloc only works with useless printf
Im trying to tokenizer the argv by the character '|' and return pointers for each command separately, for example: if argv =
Segfault accessing struct member after using realloc 4 times in c
Im getting a segfault whenever ntable->size = 4, and i cant figure out for the life of me why. i added a comment in the code where the segfault
Where am I accessing illegal memory? realloc(): invalid next size
I'm making a shell simulator for an operating systems course homework. we were asked to add a "history" command that when typed, should
Dynamically length/sized char array in c
I am attempting to create a dynamic char array (vector) in c with dynamic length/size. here is my attempt: #include
Ad
Gradually reallocating of memory leads to segmentation fault
I'm trying to append new values to c array of strings in another function, however i am able to add only three records, when i try to add fourth
Under what conditions may this function cause memory leakage?
Char *expandspace (char* test) { static int i = 0; test = realloc (test, ++i * 100); if(test == null) {
Error when reallocating dynamic unsigned char array with invalid next size error
I'm attempting to create a dynamic unsigned char array that grows in number of rows per each element added: #include
"realloc(): invalid next size" when reallocating memory a char** pointer that is a member of a struct
I just started learning c recently, and am having issues figuring out memory allocation. i have spent about the last 2~3 days in my extra time
Reading a well-formatted text file
Given the well-formatted text file called input.txt below: yesterday snowed today is hot tomorrow will rain next week will
double free or corruption (fasttop) with large files
I'm working on a program made to read big csv files. i have developped and tested it with smaller csv files for debug and it worked. but when i
sscanf a string containing variable length strings and numbers in C
I have a string such as: "1.5 3 aaa 0 bbbbbbbbbb" which i need to sscanf (i know exactly how many space-separated elements i expect and
Calling malloc and realloc from within a function gives unexpected results
#include <stdio.h> #include <stdlib.h> char _getline(char *s) { char c; s = (char *)malloc(sizeof(char)); int i;
SegFault while using Malloc/Realloc on an uninitialized pointer
I'm working on a "light drone simulator" (in c) and one of my task is to add a static target when i left click on the map. so far so good. the
How can i save a string into a pointer and redefine it using malloc? C
I'm in a loop and i want to save readed values from a fifo in a variable. char *tmp=null; char *opts=null; char
Inserting into a dynamic character array while using realloc()
I am very much wanting to catch up on my c programming skills, so i have started my own self-training program, attempting to reading files and
Ad
C problem with memory leaks (realloc function)
Scanfolderpath - path of folder with files. filestoscan - array of strings with the files name. i have problem with the realloc
Can I reuse a pointer after reallocating memory it points to?
I'm new to c. i knew that when i use realloc(), the pointer is deactivated as the new block of memory may be in another address (is
duplicate same following elements in array
I should build a function that gets an array and it's size and return a pointer to new array (i need do create new array by using malloc and
I am writing some functions for Strings, but i have a problem with realloc
I am writing some functions for strings, and im having a problem with realloc. why do i get the error realloc(): invalid pointer:
realloc throws "Access violation reading location"
I'm using visual studio 16.6.0. in some part of my c program, i have a dynamic array (myvector), which i'm trying to resize to contain a a
Is creating a long buffer and then strdup into a new variable the best way to save any input from scanf?
#include <stdio.h> int main() { int buf[1024]; if (scanf("%1023[^\n]", buf) == 1) { int *myarray = strdup(buf);
realloc an array with c
I tried to find similar title questions with mine, but i didn't find what i wanted. so here is my question. if i malloc an array with size of 10,
Realloc in C random int
I have a problem with reallocating memory of dynamically allocated array. so what i am trying to do is: typedef struct { int
realloc fails in simple dict library
I wrote a lightweight dictionary for a quick project with c, and i am getting the error: realloc(): invalid next size. i know this
How to use realloc to shorten a string array size
I've tried to take a certain string, have the string set for a certain size, 50 chars, then after all of the strings gets inputted, it will sort
Why is realloc() introducing some random values into a dynamic array when called multiple times?
I am trying to fill a dynamically generated array using a for loop and make it bigger whenever needed using realloc(). however, when realloc is
Ad
Malloc() a double nested struct in C
The goal is to have structs of type unit filling that array in struct line, and struct line filling the array in struct fulldata so it essentially
C programming: Problems reading a filetext and trying to sort out the longest word
I am beginner at coding, so i might be doing quite a few rookie mistakes here and there. we got this task in school and the goal is to sort out
increase size of array
May you help me with this exercise please? write a c program that reads 6 integers from the keyboard and assigns the first
C : Realloc doesn't work with dynamic double pointer array
I am facing some issues regarding a realloc with a double pointer dynamic array. what i would like to perform is to add 2
Segmentation fault (core dumped) error in dynamic memory allocation
I'm new to coding and new to c++. i am trying to write code in which one enters elements of the matrix. afterwards, one column should be removed,
C realloc() on a Flexible Length Array
I have the struct along with these functions on it. the purpose is to mimic a list storage/access using a preallocated array.
realloc(): invalid next size. Fail to read the http page into string
I am trying to read from the http page and save the whole page as a string. while realloc() the memory, the error occurs, stating that: realloc():
Both dynamic column and row sized 2D array updated in recursive function in c programming
I am growing a 2d array by it's column and row size in c programming. #include <stdio.h> #include <malloc.h>
How to properly realloc a bit array in C
I'm trying to grow the array of bits dynamically as more values are entered. i'm having two issues so far. i gdb'd into it and i can't really see
Realloc trouble
I have problem. i have stroke: "/hello/world" i need to copy word 'hello' to another string; i have this code: void
malloc Incorrect checksum error when trying to parse input as tokens
I'm trying to create a shell but i keep encountering the error, malloc: incorrect checksum for freed object
Ad
How to change saved address after reallocation
Struct ad_sint32type* = null; foo = (struct mystructarray*)malloc(sizeof(struct mystructarray)); foo[0].x = 45; foo[0].y = 90; coords[0] =
Error at execution because of realloc
I wrote a little console program which stores words in an array, represented by char** test_tab, and then print them.
Ad
Blog Categories
Ad