I am new to the C language and I have to create a program that registers users but when consulting them, the entered name does not appear, only its first two characters. For example, if the user is called Paco at the moment of consulting the registered users, only PA will be shown followed by a consecutive number such as PA001. Is there any way to achieve this?
#include<stdio.h>
#include<stdlib.h>
struct registro{
char nombre[100];
int opcion;
}personas[6];
int main(){
int choice;
int i;
do {
printf("Eliga una opcion:\n");
printf("1.Captura\n");
printf("2.Consulta\n");
printf("3.Salir");
scanf("%d", &choice);
if (choice==1){
printf("Captura\n");
for(i=0;i<5;i++){
fflush(stdin);
printf("Escribe tu nombre:\n",i+1);
gets(personas[i].nombre);
printf("\n");
}
for(i=0;i<5;i++){
printf("%i.Su nombre es:%s",i+1,personas[i].nombre);
printf("\n");
}
}
if (choice==2){
printf("Consulta\n");
for(i=0; i<5;i++){
printf("%i.Su nombre es:%s",i+1,personas[i].nombre);
printf("\n");
}
}
if (choice==3){
printf("Salir");
}
}while(choice !=3);
return 0;
}