The question might seem little trivial,i'm trying to write a program in C,which just eats away memory as much as it could before OOM gets invoked and kills it.Although,i initially used malloc() with memset(),i decided to try realloc() this time.I'm…
So I faced with an issues when I allocate some space, then I reallocate this space inside the recursive function and then I try to free this space outside of recursive function. Free() does not proceed any error, but as debugging shows I still have…
I am working in C with Netbeans8.0
I have to read files in an iterative approach to get list of words. That is, in single iteration a file is read into an array of strings and then merge this array into a single array.
void merge_array(char** a,int*…
We're trying to overload the delete[] operator to achieve shrinkable oriented to objects arrays.
It works fine with data types without specific destructor.
When the data type has a specified destructor, the new[] operator needs extra bytes.
Could…
I'm sure that the answer to this is me not understanding Pointers and References properly!
So at the start of my C file I define a struct for people:
typedef struct {
char id[4];
int age;
char name[128];
} people;
Then inside of main()…
I am trying to find the maximum sum leaf to root path in a Binary Tree as in below
http://www.geeksforgeeks.org/find-the-maximum-sum-path-in-a-binary-tree/
1) I am unable to find why the path doesn't get printed in the main()
Is this because of…
I was going through the relloc example in C here . I could not figure out exactly what realloc() was doing in this snippet, because even when I commented out the realloc statement the program ran just fine. I am attaching the Code here again so…
I was trying to run a program which uses a function concat_str. It can take in multiple arguments as strings and the end of arguments is denoted by "quit". The code for my function is given below:
char *concat_str(char *str1, ...)
{
va_list…
Using the std::realloc function:
If the new size is smaller, does it always have warranty to keep the memory block on the same position and only make it smaller, or it can move sometimes the whole block?
The reason to ask this, is that we'are…
Some starters:
creating a dynamic array of a data structure called fractions.
Fractions has functions for setting, printing, intiting etc.
I kept getting an error for double freeing or corruption, along with a lot of gibberish from the memory…
I have some problem with realloc():
int main(int argc, char* argv[])
{
int* amis;
int saisie, cpt = 1;
while(saisie != -1) {
printf("Entrer les notes -1 pour quitter :");
scanf("%d", &saisie);
if (cpt == 1) {
…
I am getting a bus error in a huge application that I have when I try to reallocate a 2d int array. Trying to narrow down the problem, I generated a small code only with the reallocations. Question: Valgrind complains a bit without crashing. Are…
I need to allocate space for a temporary array once per iteration. I try to use realloc each iteration to optimize memory using. Like that:
int *a = (int*)std::alloc(2 * sizeof(int));
for(int i=0; i
Although there were several answers here regarding this issue: I still couldn't fit them to the following code, as it segfault on the 4th iteration of processFile:
#include
#include
#include
#include…