Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
1 answer
28 views

Can't put values together into struct that is initiated by pointer and malloc [duplicate]

Just a simple struct called person, inside I need to store name and age. I'm trying to dynamically allocate memory for my struct. Without using pointer: #include <stdio.h> #include <stdlib.h&...
cutelittlebunny's user avatar
-6 votes
2 answers
71 views

malloc(): corrupted top size on deleting an entry from binary file [closed]

I AM CREATING A SCHOOL MANAGEMENT SYSTEM . WHEN I TRY TO DELETE A STUDENT AFTER ADDING ONE I AM GETTING "malloc(): corrupted top size" ERROR .CANT FIND THE REASON.I AM A BEGINNER , HELP ...
ASHNA A's user avatar
0 votes
1 answer
53 views

How to get rid of C6387 warning on call to fwrite function?

In Visual Studio 2022, I am getting the following warning when I call fwrite. Warning image C6387 It says: C6387:'fout' could be '0': this does not adhere to the specification for the function 'fwrite'...
lussco's user avatar
  • 3
0 votes
0 answers
17 views

Initializing an array created with malloc with arbitrary values

I need to create large float arrays using malloc, to be able to free the memory when I don't need the array anymore. The values are arbitrary, meaning they are not all zeros or ones, much more random ...
Fabrice Auzanneau's user avatar
0 votes
0 answers
69 views

How do I solve "realloc(): invalid next size" error?

Here is the section of code where my program crashes: if (fromNode != toNode) { pthread_mutex_lock(&mtxs[fromNode]); g->out[fromNode]++; if (g->in[toNode].index == g->in[...
XOpt 6's user avatar
  • 11
0 votes
3 answers
87 views

Error in assigning values to memory location with for loop [duplicate]

I have just entered the world of C programming, and I'm currently learning how to use malloc & free. I've written a short excercise code to printf the string entered with scanf, and I am having ...
Woodrow's user avatar
  • 27
4 votes
2 answers
125 views

Function to clear allocated memory is not working

I'm trying to make a DTC in C. This is the structure of the nodes: typedef struct node { int value; struct node *lower; struct node *higher; } node; To free the memory allocated using ...
Sarvesh Pande's user avatar
3 votes
2 answers
148 views

Malloc sometimes fails immediately after a free

I want to test my code in low memory situations. I wrote this function with setrlimit to limit the available memory : unsigned short int oom_enable = 0; char* _oomfill = NULL; uint32_t oom_setup(...
François Cerbelle's user avatar
0 votes
1 answer
35 views

How to know heap overflow point?

I'm attempting to write a program that determines all palindrome within a given range. My program calls a function (number of digits) that returns the size of an integer (ie. 400 would be 3 as it has ...
Ratdude's user avatar
  • 67
1 vote
1 answer
78 views

wrong values when displayed : C pointer or malloc issue?

My program multiplies a matrix 1 by a matrix 2. The matrix 3 is the result. I can display matrix 1 and matrix 2 with the correct values but I am not able to display though the same function the ...
EagleStar's user avatar
  • 199
0 votes
3 answers
116 views

Using the malloc function once initializes all uninitialized variables with a 0

The malloc function is not supposed to initialize any value to any variable it is used on, like the calloc function does. Why then do I keep getting the initialized value of even other varibales to ...
Aditya Bhardwaj's user avatar
0 votes
0 answers
87 views

How to catch and fix a memory leakage?

I wrote a shell-like program and I have a memory leakage that I'm unable to fix. in case of invalid_command && command1 || command2 (and it happens only in this case, everything else working ...
Johnnie's user avatar
0 votes
1 answer
53 views

Nothing prints when i type input into the serial monitor

I am new to Arduino. I am trying to learn how to use receive data over USB, but it is not working. This is my code: struct arrayData{ char* array; int size; }; void setup() { // put your ...
person's user avatar
  • 11
2 votes
1 answer
66 views

Unable to debug python C extension using valgrind

I am trying to debug a C extension I made using CFFI. I am using Python 3.11 and Valgrind 3.18.1. As far as I can tell from the docs the only setup needed is setting the PYTHONMALLOC=malloc ...
Slav's user avatar
  • 357
1 vote
2 answers
103 views

Troubleshooting malloc Usage and heap_size Configuration in STM32 Development

I'm currently working with ST's ARM-M4 chip to develop a program and have ported a networking library. During debugging, I've noticed that if I don't increase the heap_size in my .s file to 0x400, the ...
kanghao chen's user avatar

15 30 50 per page
1
2 3 4 5
514