Here, I am trying to enter the first name and last name as "Firstname Lastname". I want to get the output as "Lastname, FN." where FN is the first letter of first name.
Example: Input= "James Garcia" ; Output="Garcia, J."
Please find the error in my code.
#include <stdio.h>
int main () {
char fn[20],ln[20];
printf("Enter a first name and a last name:");
scanf("%c %s",&fn,&ln);
printf("%s, %c.",ln,fn);
return(0);
}