Posts

Showing posts from August, 2011

Callback functon - Fixed

I just love people who make the effort and help to teach others new stuff. But with code samples i don't understand why you don't test the code before publishing. I found an interesting example off callback function example but it was not working. Here is the proper stuff:) #include <stdio.h> #include <stdlib.h> typedef struct {   int age ;   char name [ 10 ] ;   char surname [ 10 ] ;         } person ; // Simple fuction to be called as callback void callMe ( person * m ) {   printf ( "%d %s %s \n \r " , m -> age , m -> name , m -> surname ) ; } int main ( int argc , char * argv [ ] ) {   // Declaration of pointer to function with same signiture as callMe   void ( * callback ) ( person * ) ;   // Create struct and fill with data   person s ;   s. age = 27 ;   //Don't forget how to copy strings in C/C++   strcpy ( s. name , "Dejan" ) ;