C language ---- function pointer
Callback Function
1. function pointer Parameters
2. Callback Process
Sample Code
/// Main. m // C_Project_12 // Created by on 15/3/26. // Copyright (c) 2015. All rights reserved. // # import
// Exercise questions in the classroom: Write a function to search for students with scores higher than 90? Add "? Gao fushuai ". // 1. define the struct type typedef struct student {char name [20]; float score;} Student; Student * generateStudentsInfo (int count) {Student * stus = malloc (sizeof (Student) * count); for (int I = 0; I <count; I ++) {printf ("enter the information of student % d \ n", I + 1); printf ("name:"); scanf ("% s ", (stus + I)-> name); printf ("score:"); scanf ("% f", & (stus + I)-> score );} return stus;} void printStudentsInfo (Student * stus, int count); void printStudentsInfo (Student * stus, int count) {printf ("\ n --------------------------- \ n "); for (int I = 0; I <count; I ++) {printf ("Name: % s \ t score: %. 2f \ n ", (stus + I)-> name, (stus + I)-> score);} printf (" \ n ------------------------- \ n ");} void modifyName (char * name); void modifyName (char * name) {strcat (name, "-Gao fushuai");} void searchStudentInfo (Student * stus, int count, float score, void (* point) (char *); void searchStudentInfo (Student * stus, int count, float score, void (* point) (char *)) {for (int I = 0; I <count; I ++) {if (stus + I)-> score) {point (stus + I) -> name) ;}} int main (int argc, const char * argv []) {Student * stus = generateStudentsInfo (2); printStudentsInfo (stus, 2 ); searchStudentInfo (stus, 2, 90, modifyName); printStudentsInfo (stus, 2); return 0 ;}