wieso funktioniert mein malloc so nicht?
Code: Alles auswählen
#include"malloc.h"
void check_malloc(size_t bytes);
double test;
int main()
{
test = (double *)check_malloc(5*sizeof( double ));
}
Code: Alles auswählen
#include <stdio.h>
#include <math.h>
#include <float.h>
#include <string.h>
void check_malloc(size_t bytes);
void check_malloc(size_t bytes)
{
void *tmp;
tmp= (void*) malloc(bytes);
if(tmp==NULL)
{
fprintf(stderr, "ERROR : Out of memory ?!\n"
" Trying to (m)allocate %i Bytes failed !\n"
" File: %s Line: %d\n", (int) bytes);
exit(1);
}
return tmp;
}
In file included from malloc.c:5:
../malloc.h: In function `check_malloc':
../malloc.h:19: warning: `return' with a value, in function returning void
malloc.c: In function `main':
malloc.c:11: error: void value not ignored as it ought to be
merci,
nakaa