# get_next_line ファイルデスクリプタを引数として受け取り、次の改行か終端文字までをreturnする関数を書いてください。 ``` char *get_next_line(int fd); ``` 1回目に呼ばれた時には1行目、2回目に呼ばれた時には2行目を返してください。もう返す行がない時はNULLを返してください。 ## Example Program ``` #include <stdio.h> #include "get_next_line.h" int main(int argc, char **argv) { int fd; char *s; s = "let's start"; fd = open(argv[1]); while (s != NULL) { s = get_next_line(fd); printf("%s", s); } return (0); } ``` ``` $> printf "hello\nworld\n" > hello.txt $> ./get_next_line hello.txt hello world ``` ``` $> printf "hello\nworld\nlet's live code." > sample.txt $> ./get_next_line sample.txt hello world let's live code.% ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up