From 00672c4b221995cc0125df5ec5a4d705fd9955aa Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 23 Mar 2023 21:35:21 +0100 Subject: [PATCH] apps/hello: Demo fgets --- apps/hello.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/hello.c b/apps/hello.c index 5775bd0b..dea0b7e9 100644 --- a/apps/hello.c +++ b/apps/hello.c @@ -3,4 +3,10 @@ int main(int argc, char** argv) { printf("Hello world! argc=%d, argv[0]=%s, argv[1]=%s, argv[2]=%s\n", argc, argv[0], argv[1], argv[2]); + + char buf[1024]; + char* rc = fgets(buf, sizeof(buf), stdin); + if (!rc) perror("fgets"); + + fputs(buf, stdout); }