#include "my_c_tail.h" #include #include void stdintail(unsigned int n) { char **lines = calloc(2000, sizeof(char *)); lines[0] = malloc(350 * sizeof(char)); size_t m = 0; char c; size_t i = 0; while (read(STDIN_FILENO, &c, 1)) { if (c == '\n') { lines[m][i] = '\0'; lines[++m] = malloc(350 * sizeof(char)); i = 0; } else { lines[m][i++] = c; } } size_t j; if (m > n) { for (size_t i = 0; i < m - n; i++) free(lines[i]); j = m - n; } else j = 0; for (; j < m; j++) { for (size_t i = 0; lines[j][i]; i++) write(STDOUT_FILENO, &(lines[j][i]), 1); write(STDOUT_FILENO, "\n", 1); free(lines[j]); } free(lines[m]); free(lines); }