| 1 | // RUN: %clangxx -O0 -g %s -o %t && %run %t |
|---|---|
| 2 | // fgetln is BSD-only. |
| 3 | // UNSUPPORTED: target={{.*(linux|solaris).*}} |
| 4 | |
| 5 | #include <assert.h> |
| 6 | #include <stdio.h> |
| 7 | #include <stdlib.h> |
| 8 | |
| 9 | int main(void) { |
| 10 | FILE *fp = fopen(filename: "/etc/hosts", modes: "r"); |
| 11 | assert(fp); |
| 12 | |
| 13 | size_t len; |
| 14 | char *s = fgetln(fp, &len); |
| 15 | |
| 16 | printf(format: "%.*s\n", (int)len, s); |
| 17 | |
| 18 | assert(!fclose(fp)); |
| 19 | |
| 20 | return 0; |
| 21 | } |
| 22 |
