I am applying the queue concept in a program, the program can log data, display it and delete it. This is the structure I use:
struct personal {
char nombre [40];
char apellido [40];
int edad;
float sueldo;
} ;
int j,i =0; //indices
int opc=0;
char k [3];
personal cliente [100];
My problem is at the time of deleting the data, I want to delete the data from the starting position (0) and then shift back the remaining data:
void elimina(){
do{
system("cls");
printf("\n EL CLIENTE A ELIMINAR ES : \n ");
printf("\n nombre : %s \n ",cliente[0].nombre );
printf("\n apellido: %s \n ",cliente[0].apellido );
printf("\n edad : %d \n ",cliente[0].edad );
printf("\n sueldo : %f \n ",cliente[0].sueldo );
for ( j = 0; j < i; j++)
{
cliente[j].nombre= cliente[j+1].nombre; //Intento fallido
cliente[j].apellido= cliente[j+1].apellido; //Intento fallido
cliente[j].edad = cliente[j+1].edad;
cliente[j].sueldo = cliente[j+1].sueldo ;
}
printf("\n Desea elimnar otro cliente: [si=1/no=2] \n");
scanf("%d" ,&opc);
i--;
getch();
}while (opc==1 && i>0);
}
The variable cliente[j].edad
and cliente[j].sueldo
are moved correctly, my problem is with string variables, I don't know how to move them. There I tried, but it does not work correctly.