typedef struct person{
char code[20];
char name[100];
struct person *next;
} ListPerson;
typedef ListPerson *PersonPtr;
hi , i have a linked list structure like above.
code stores a 10 digits numbers
ie 1234567891
how can i only extract the first two digits of code, ie , in this case 12
i tried this
void searchCode(PersonPtr list,char cmd[20]){
PersonPtr tmp;
char command[MAXCODE];
int i;
for(tmp=list;tmp!=NULL;tmp=tmp->next){
for(i=0;i<2;i++){
command[i] = tmp->code[i];
if(strcmp(command,cmd)==0){
printf("%s,%s",tmp->ode,tmp->name)
return;
}
}
but it doesn't work ><
can someone help me ?