The code looks like this:
Copy Code code as follows:
typedef struct ST_TEST
{
int id;
Char *pname;
Char class[10];
}student;
VOID fn (Student *pstud) {
Pstud->id = 10;
Pstud->pname = "Tom simith";
strcpy (Pstud->class, "Class 1");
printf ("sizeof (Pstud) =%d/n", sizeof (Pstud)); sizeof (Pstud) = 4
printf ("sizeof (pstud->id) =%d/n", sizeof (Pstud->id)); sizeof (PSTUD->ID) = 4
printf ("id:%d/n", pstud->id); Id:10
printf ("sizeof (pstud->pname) =%d/n", sizeof (Pstud->pname)); sizeof (pstud->pname) = 4
printf ("strlen (pstud->pname) =%d/n", strlen (Pstud->pname)); strlen (pstud->pname) = 10
printf ("name:%s/n", pstud->pname); Name:tom Simith
printf ("sizeof (pstud->class) =%d/n", sizeof (Pstud->class)); sizeof (Pstud->class) = 10
printf ("strlen (pstud->class) =%d/n", strlen (Pstud->class)); strlen (Pstud->class) = 7
printf ("class:%s/n", Pstud->class); Class:class 1
}
void Fnarray (char arr[]) {
printf ("arr:%s/n", arr); Arr:hello
printf ("sizeof (arr) =%d/n", sizeof (arr)); sizeof (ARR) = 4 the length of pointer
printf ("strlen (arr) =%d/n", strlen (arr)); strlen (arr) = 5 The length of array
}
int main (int argc, char **argv)
{
Student Stud;
FN (&stud);
Fnarray ("Hello");
return 0;
}