When I compile this code asCode:int main( ) { char *words[ ] = { "Then", "he", "shouted", "What", "I", "didn't", "hear", "what", "you", "said" }; int j = 0; int n = sizeof(words) / sizeof(char *); qsort( words, n, sizeof(char *), strptrcmp ); for ( j = 0 ; j < n ; j++ ) puts( words[j] ); } int strptrcmp( const void *sp1, const void *sp2 ) // Compare two strings by reference. { // qsort( ) passes a pointer to the pointer: // dereference it to pass a char * to strcmp. const char * s1 = *(char **)sp1; const char * s2 = *(char **)sp2; return strcmp( s1, s2 ); }I get the compiler error...Code:const char *s1 = *(char *) sp1; const char *s2 = *(char *) sp2;
initialization makes pointer from integer without a cast
What does it mean?



LinkBack URL
About LinkBacks



