i can't make sense of segmentation fault i'm getting out of following code:
#include <stdio.h> #include <jpeglib.h> #include <stdlib.h> int main(int argc, char** argv){ file* outfile; jsample* row_pointer; struct jpeg_error_mgr jerr; long long int *w, *h; setsomepointers(w, h); printf( "%lld %lld\n", *w, *h); }
commenting out 1 of first 3 declarations fix it...
oddly, following code works:
#include <stdio.h> #include <jpeglib.h> #include <stdlib.h> int main(int argc, char** argv){ file* outfile; jsample* row_pointer; struct jpeg_error_mgr jerr; long long int w, h; setsomepointers(&w, &h); printf( "%lld %lld\n", w, h); }
is there strange happening, or need hit c tutorials?
this totally undefined behavior - dereference uninitialized pointers.
the actual problem in
printf( "%lld %lld\n", *w, *h);
the other things declarations. should not dereference w
, h
, not initialized @ all. has nothing commenting/uncommenting of first (3) lines.
Comments
Post a Comment