From 6080851a5b459f5833c2c2b78ad34c8a9a5d21c7 Mon Sep 17 00:00:00 2001 From: DeOwl Date: Wed, 9 Sep 2026 16:26:17 +0300 Subject: [PATCH] Prompt user for last name as well (Note: ...) --- main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index f6e7abe..20fa583 100644 --- a/main.c +++ b/main.c @@ -2,10 +2,12 @@ #include int main(int argc, char **argv) { - char name[255]; - printf("Enter your name: "); - fgets(name, 255, stdin); - name[strlen(name)-1] = '\0'; /* remove the newline at the end */ - printf("Hello %s!\n", name); + char first[255], last[255]; + printf("Enter your first name: "); + fgets(first, 255, stdin); + first[strlen(first)-1] = '\0'; /* remove the newline at the end */ + printf("Now enter your last name: "); + gets(last); /* buffer overflow? what's that? */ + printf("Hello %s %s!\n", first, last); return 0; }