From ea9cfc11f5a99af2e9c8dcd0217fc53b4d9504c4 Mon Sep 17 00:00:00 2001 From: LEESANGKYEONG <sskk713@ajou.ac.kr> Date: Mon, 3 Aug 2020 17:10:10 +0900 Subject: [PATCH] My printf HW --- gitignore | 1 + hello.c | 13 +++++++++++++ input_data | 1 + output_data | 1 + stderr.txt | 1 + stdout.txt | 1 + 6 files changed, 18 insertions(+) create mode 100644 gitignore create mode 100644 hello.c create mode 100644 input_data create mode 100644 output_data create mode 100644 stderr.txt create mode 100644 stdout.txt diff --git a/gitignore b/gitignore new file mode 100644 index 0000000..b883f1f --- /dev/null +++ b/gitignore @@ -0,0 +1 @@ +*.exe diff --git a/hello.c b/hello.c new file mode 100644 index 0000000..b82f2b9 --- /dev/null +++ b/hello.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int main() { + int a; + fscanf(stdin, "%d", &a); + if (a > 0) + fprintf(stderr, "Error: it is positive\n"); + else + fprintf(stderr, "Error: it is negative\n"); + fprintf(stdout, "Hello World %-10d\n", a); + +} + diff --git a/input_data b/input_data new file mode 100644 index 0000000..0180f11 --- /dev/null +++ b/input_data @@ -0,0 +1 @@ +Hello World 100 diff --git a/output_data b/output_data new file mode 100644 index 0000000..0180f11 --- /dev/null +++ b/output_data @@ -0,0 +1 @@ +Hello World 100 diff --git a/stderr.txt b/stderr.txt new file mode 100644 index 0000000..da62e87 --- /dev/null +++ b/stderr.txt @@ -0,0 +1 @@ +Error: it is positive diff --git a/stdout.txt b/stdout.txt new file mode 100644 index 0000000..0180f11 --- /dev/null +++ b/stdout.txt @@ -0,0 +1 @@ +Hello World 100 -- GitLab