Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
[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);

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!


This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho