My code has a bug in command gets()
cant input string name. How can I do this?
#include <stdio.h>
#include <string.h>
struct letter {
char name[20];
char address[30];
char message[40];
};
int n,i;
main() {
printf("Please enter number of employee: ");
scanf("%d",&n);
struct letter first[n];
//1. Keep an information
for(i=0; i<n; i++) {
//gets() does not work what wrong with this
printf("Enter name[%d] : ",i);
gets(first[i].name);
printf("\nEnter address[%d] : ",i);
scanf("%s",first[i].address);
strcpy(first[i].message, "How r u?");
}
// Show an information
for(i=0; i<n; i++) {
printf("\nNAME[%d] is %s",i,first[i].name);
printf("\nAddress[%d] is %s",i,first[i].address);
printf("\nMessage : %s",first[i].message);
}
}