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
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
[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.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho