#include #include #include int main(int argc, char *argv[]) { unsigned long sz; void *ptr; char *endptr; if (argc != 2) { fprintf(stderr, "usage: %s bytes\n", argv[0]); return 1; } errno = 0; sz = strtoul(argv[1], &endptr, 10); if (errno || (argv[1] == endptr)) { fprintf(stderr, "invalid value\n"); return 1; } fprintf(stderr, "trying %lu bytes... ", sz); ptr = malloc(sz); fprintf(stderr, "got %p\n", ptr); return 0; }