Memory allocation with malloc
I got a problem with the malloc function. The purpose of this program is to try to allocate memory to an extend when the system won't allocate memory anymore.
int * buffer;
counter = 0;
/*buffer = (int*) malloc (102400*sizeof(int));*/
buffer = (int *)malloc(sizeof(int));
*buffer = 1024;
printf("buffer: %d\n", *buffer);
*buffer = *buffer + 1024;
printf("count: %d\n", *buffer);
printf("Error allocating memory!\n");
When I compile and run the code it keeps on going and it will eventually run in -(number). While it should give an error with the allocation of memory.
So I don't know what I did now, maybe someone else has a solution for it.