diff options
Diffstat (limited to 'rushs/tinyprintf/my_c_tail')
| -rw-r--r-- | rushs/tinyprintf/my_c_tail/main.c | 10 | ||||
| -rw-r--r-- | rushs/tinyprintf/my_c_tail/my_c_tail.c | 46 | ||||
| -rw-r--r-- | rushs/tinyprintf/my_c_tail/my_c_tail.h | 6 |
3 files changed, 0 insertions, 62 deletions
diff --git a/rushs/tinyprintf/my_c_tail/main.c b/rushs/tinyprintf/my_c_tail/main.c deleted file mode 100644 index ba33337..0000000 --- a/rushs/tinyprintf/my_c_tail/main.c +++ /dev/null @@ -1,10 +0,0 @@ -#include <stdlib.h> - -#include "my_c_tail.h" - -int main(int argc, char *argv[]) -{ - if (argc > 1) - stdintail(atoi(argv[1])); - return 0; -} diff --git a/rushs/tinyprintf/my_c_tail/my_c_tail.c b/rushs/tinyprintf/my_c_tail/my_c_tail.c deleted file mode 100644 index 790240c..0000000 --- a/rushs/tinyprintf/my_c_tail/my_c_tail.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "my_c_tail.h"
-
-#include <stdlib.h>
-#include <unistd.h>
-
-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);
-}
diff --git a/rushs/tinyprintf/my_c_tail/my_c_tail.h b/rushs/tinyprintf/my_c_tail/my_c_tail.h deleted file mode 100644 index 172c844..0000000 --- a/rushs/tinyprintf/my_c_tail/my_c_tail.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MY_C_TAIL_H -#define MY_C_TAIL_H - -void stdintail(unsigned int n); - -#endif // MY_C_TAIL_H |
