But expected output is:
Liam 786798
Emma 099799
How can print the name and phone number of each user on the same line?
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
char name[2][20];
char p[2][20];
for (int i=0; i<2; ++i) {
printf("Person %d: ", i+1);
fgets(name[i], sizeof name, stdin);
printf("Phone: ");
fgets(p[i], sizeof p, stdin);
}
printf("\n");
for (int i=0; i<2; ++i) {
printf("%s\t\t%s", name[i], p[i]);
}
return 0;
}