Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *str = NULL
- size_t len = 0;
- size_t n;
- char buf[SIZ];
- while ((n = fread(buf, 1, sizeof(buf), stdin)))
- {
- str = realloc(str, len + n + 1); // Extend the buffer
- memcpy(str+len, buf, n); // Append to the string
- len += n;
- }
- str[len] = 0;
- printf("ALLOC'D: %zu", len);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement