case 3 is the troubled zone, an integer array is working, it's fine, but "first" and "last" string arrays aren't working at all. I don't know how to solve it.
I have to use only stdio.h and stdlib.h libraries."first" and "last" are 2d char pointers, I'd like to 20 elements and maximum 30 characters.Adding ,and editing are fine it's working, but "first[temp]=first[temp+1];" this code cause compiler error when I try "strcpy(first[temp],first[temp+1]);" there is no compiler error.
Eventually using strcpy. when I want to delete the strings remain the same, and the integers take the value of 0
int main(){
printf("Welcome to address book ! \n ");
printf("--------------------------------------------------------\n");
int a=0;
int temp=0;
char* first[20][30];
char* last[20][30];
int n[20];
int g=0;
while(a<=1000){
int b=0;
printf("What do you want? \n");
printf("1-New ID\n2-Edit ID\n3-Delete ID\n4-List All ID's\n5-Close the Program\n");
printf("--------------------------------------------------------\n");
scanf("%d",&b);
switch(b){
case 1:
printf("Enter Fist Name \n");
scanf("%s",&first[g]);
printf("Enter Last Name\n");
scanf("%s",&last[g]);
printf("Enter Student Number\n");
scanf("%d",&n[g]);
g++;
a++;
continue;
case 2:
printf("Which user you want to change ?\n");
printf("user sequence :");
scanf("%d",&temp);
temp=temp-1;
printf("Listed First Name : %s\n",first[temp]);
printf("New First Name : ");
scanf("%s",&first[temp]);
printf("Listed Last Name : %s\n",last[temp]);
printf("New Last Name : ");
scanf("%s",&last[temp]);
printf("Listed Number : %d\n",n[temp]);
printf("New Listed Number : ");
scanf("%d",&n[temp]);
temp=0;
a++;
continue;
case 3:
printf("which user do you want to delete :");
scanf("%d",&temp);
if(temp+1<=g){
// first[temp]=first[temp+1];
// last[temp]=last[temp+1];
n[temp]=n[temp+1];
}
else
printf("unavailable");
a++;
continue;
case 4:
printf("--------------------------------------------------------\n");
int u;
for(u=0;u<g;u++){
printf(">%d.user. ",u+1);
printf("%d\t",n[u]);
printf("%s\t",first[u]);
printf("%s\n",last[u]);
}
printf("\n--------------------------------------------------------\n");
a++;
continue;
case 5:
printf("\nThank you for the use this program !\n ");
temp= 1000-a;
a= a+temp;
a++;
continue;
}
}
return 0;}