diff options
| author | yctct <yctct@yctct.com> | 2026-02-17 09:20:01 +0100 |
|---|---|---|
| committer | yctct <yctct@yctct.com> | 2026-02-17 09:20:01 +0100 |
| commit | 7fd21dc25dc31a3807962a3d1489fbfcb951b717 (patch) | |
| tree | c8e48844290a95fe672a09cd48815b39108ea297 /main.c | |
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -0,0 +1,40 @@ +/* +ft_getline Copyright (C) 2026 yctct + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ + + +#include "ft_getline.h" +#include <fcntl.h> +#include <unistd.h> + +int main(void) +{ + int fd; + char *line; + + fd = 0; + fd = open("file.txt", O_RDONLY | O_CREAT); + while (1) + { + line = ft_getline(fd); + if (line == NULL) + break ; + printf("%s", line); + printf("\n"); + free(line); + } + close(fd); +} |
