Implement strerror() #5

Merged
apio merged 2 commits from strerror into main 2022-10-08 10:32:12 +00:00
Showing only changes of commit 21e8ea1486 - Show all commits

View File

@ -1,6 +1,7 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#define CHUNK 4194304 // 4 MB #define CHUNK 4194304 // 4 MB
@ -14,6 +15,6 @@ int main()
printf("Allocating 4 MB of memory... %lx\n", (unsigned long)allocated); printf("Allocating 4 MB of memory... %lx\n", (unsigned long)allocated);
sleep(1); sleep(1);
} while ((allocated = malloc(CHUNK))); } while ((allocated = malloc(CHUNK)));
printf("Out of memory. (errno=%d)\n", errno); printf("Out of memory. (errno=%d, %s)\n", errno, strerror(errno));
printf("Press any key to restart.\n"); printf("Press any key to restart.\n");
} }