I'm I complete newbie and I found out about fgets only last night! I used it and seemed to have worked the first time but skips the code on the second string.
#include <stdio.h>
#include <string.h>
int main() {
char name[100];
char address[500];
int age;
printf("Input your personal details\n");
printf("Name: ");
fgets(name, 100, stdin);
name[strlen(name)-1] = '\0';
printf("Age: ");
scanf("%d", &age);
printf("Address: ");
fgets(address, 500, stdin);
address[strlen(address)-1] = '\0';
printf("\nHello, %s, how are you?\n", name);
printf("%d\n", age);
printf("%s", address);
return 0;
}
The output is then
Name: Taylor Swift
Age: 18
Address:
Hello, Taylor Swift, how are you?
18