+ 1
taking input from user | C
I am trying to use gets and scanf functions but where am i doing wrong? #include <stdio.h> int main() { int age; char name[25], hometown[15]; printf("What\'s your name: \n" ); gets(name); printf("Where are you from: \n"); gets(hometown); printf("How old are you: \n"); scanf("%d", &age); printf("Welcome to %d club, ", age); printf("%s", name); printf(" from %s! ", hometown); getch(); return 0; }
4 Answers
+ 3
Can you tell me why you created an array for the <age> variable? your code will execute if you use a regular int variable rather than an array of int.
+ 3
check here
give input like this in separate line
name
hometown
age
https://code.sololearn.com/cbBD3ZAGs1xy/?ref=app
+ 2
thanks for the answers, I don't know why I did this đ I guess I was just trying something and forgot to delete it. Anyways thanks đ
+ 1
volfr
Please don't mark my response, it was a confirmation rather than an answer. Mark a response which provides a solution that you found to be helpful đ