int main(int argc, char** argv) { //Local Declaration char last_name[20]; char first_name[20]; char phone_number[20]; char address[30]; //Statement printf("Enter your last name: "); fgets(last_name, 20, stdin); printf("Enter your first name: "); fgets(first_name, 20, stdin); printf("Enter your phone number: "); fgets(phone_number, 20, stdin); printf("Enter your address: "); fgets(address, 30, stdin); printf("=====Address book=====\n"); printf("Name: %s%s\n", first_name, last_name); printf("Phone Number: %s\n", phone_number); printf("Address: %s\n", address); return (EXIT_SUCCESS); } The result doesn't come out as I expected... I meant the first name and last name to be in one line (e.g. Mark Zuckerberg). But it comes out like this
Mark
Zuckerberg
What is wrong here? Why is there a new line in between?
fgetsdoesn't skip '\n', thats your work