python (12.9k questions)
javascript (9.2k questions)
reactjs (4.7k questions)
java (4.2k questions)
java (4.2k questions)
c# (3.5k questions)
c# (3.5k questions)
html (3.3k questions)
C - Memory Leak, function return Char*
Doing a refresh on C programming, and I'm having an issue with freeing memory. The below program gives me the below compiler warnings that I'm having a hard time solving for. Valgrind is also informin...
NullPointer
Votes: 0
Answers: 1
ANSI C - Why malloc and free dont work for char pointers?
When I try to run this code:
char *s;
s = (char *) malloc (15);
s = "hello world";
free(s);
using gcc ts.c -ansi -Wall the result is:
free(): invalid pointer
Aborted (core dumped)
and the ...
alon ohana
Votes: 0
Answers: 1
How could I delete only one element from a node from the list I have?
My fuctions for insert and display look like below:
int push_front( Node **head, int rollnumber, int src, int dst, double gentime )
{
Node *new_node = malloc( sizeof( Node ) );
int success = n...
wajaap
Votes: 0
Answers: 1
Having a problem with free function in C?
I am a beginner at coding and have a problem with my code. please advice.
Input:-
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int *list = malloc(3 * sizeof(int));
if ...
Moksh Bansal
Votes: 0
Answers: 1