i am new user of linux programming!!
i need ur help!!
the output is:Code:#include <stdio.h> void *mymalloc(size_t request); int main() { char * test; int i = 0; test = (char *)mymalloc(sizeof(char) * 6); if (test == NULL) { printf("Malloc failed\n"); exit(1); } while(1) { test[i] = 'a'; printf("%d bytes written to memory\n", i+1); i++; } return 0; } void * mymalloc(size_t request) { return sbrk(request); }
2565 bytes written to memory
2566 bytes written to memory
2567 bytes written to memory
2568 bytes written to memory
Segmentation fault
my question is wat is going on this code???can anyone explain to me ??? y izzit segmentation fault after 2568 bytes ???
another question is wat should i do if i want to improve the mymalloc() function?
thanks all!!