| |||||||||||
[C] error returning array pointer from function Posted by hycheah (hycheah), 2 January 2010 I get this error from my compilation. But I am running out of ideas on how to fix them:mand_sw.c: In function `fix_mandelbrot': mand_sw.c:94: warning: assignment from incompatible pointer type mand_sw.c: In function `main': mand_sw.c:161: error: incompatible types in assignment mand_sw.c:166: warning: assignment makes integer from pointer without a cast Posted by hycheah (hycheah), 2 January 2010 Sorry, here is the code. I think my mistake is in the passing of the array pointers, but i don't really know how to fix it. Been fixing it for quite a time now.int * fix_mandelbrot( ... ) { int pixelValue; static int pixel_array[YSIZE][XSIZE]; .... .... if (k != max_iterations) { pixelValue = k > 255 ? 255 : k; } pixel_array[j][i] = pixelValue; } return (pixel_array); } int main(int argc, char *argv[]) { int * array[YSIZE][XSIZE]; array = fix_mandelbrot( ...); for (j = 0; j < YSIZE; j++) { for (i = 0; i < XSIZE; i++) { R = G = B = &array[j][i]; putc( B, outfile); putc( G, outfile); putc( R, outfile); } } return(0); } Posted by admin (Graham Ellis), 2 January 2010 I think you have a pointer to a pointer to a pointer in the calling code, but just a pointer in the function. Hard to tell exactly where the errors are, though, without line numbers ...It would be an idea to 'reduce' the problem to a few lines without all thr "..." stuff ... and perhaps for you to use our "ask the tutor" forum as Opentalk is now really just an archive ... I'm not coming by very often these days and it was a stroke of good luck I checked today! Graham This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |