Home > Back-end >  A pointer to the topic
A pointer to the topic

Time:10-08

/* * *
1. Read the following code, and points out that the level of a pointer, the role of the secondary pointer in the following program, if why use level of the secondary pointer?
2. In set_Studnet (Student * * TMP) function, specification (* TMP) [I], (* TMP + I), (* (* TMP + I)) assignment methods, as well as the similarities and differences of
3. Write a free function
4. Try to use today's learning content to make a simple translator (Chinese and English translation, translation will temporarily saved in a text file, you can use the chain table)
* * *
#include
#include
#include
# define MAX 100

Typedef struct Student {
Int number;
Char name [20].
} Student, * StudentList;

Int init (Student * * TMP) {
* TMP=(Student *) malloc (sizeof (Student) * MAX);
If (* TMP==NULL) {
Printf (" init Error!!!!!! \n");
exit;
}
return 0;
}
Int set_Studnet (Student * * TMP) {
Int I=0;
For (I; I[I].//TMP (*) number=I + 1;
//(* TMP + I) - & gt; Number=I + 1;
TMP + I) (* (*) number=I + 1;
Strcpy (TMP) (* [I]. Name, "nihao");
}
return 1;
}
Int print_Student (TMP) Student * {
Int I=0;
For (I; IPrintf (" student number is: % d \ t ", (TMP) [I] number);
Printf (" student number is: % s \ n ", (TMP) [I] name);
}
return 1;
}
Int main () {
Student * a;
//initialize the space
Init (& amp; A);
//loop setting corresponding value
Set_Studnet (& amp; A);
//printf (" name: % s. Student id: % d ", a.n ame, a.n umber);
Print_Student (a);
return 0;
}
  • Related