home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / mac / programm / 18117 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.7 KB  |  45 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wupost!udel!sbcs.sunysb.edu!sbcs!cstrockb
  3. From: cstrockb@cs.sunysb.edu (Caleb Strockbine)
  4. Subject: How to use large arrays in Think C?
  5. Message-ID: <CSTROCKB.92Nov6235644@csws12.cs.sunysb.edu>
  6. Sender: usenet@sbcs.sunysb.edu (Usenet poster)
  7. Nntp-Posting-Host: csws12.ic.sunysb.edu
  8. Organization: SUNY at Stony Brook Computer Science Dept.
  9. Distribution: comp
  10. Date: Sat, 7 Nov 1992 04:56:44 GMT
  11. Lines: 32
  12.  
  13.  
  14. Forgive me if I should have been able to figure this out on my own, but
  15. deadlines are approaching and I need to get to work...
  16.  
  17. I know that I can't declare arrays > 32K in Think C on the stack. Fine,
  18. I don't mind using malloc(). But I'm working on a project for a class
  19. in which I have to process images that are 256x256 pixels, and the images
  20. are stored (on a unix system) as 256x256 byte files (each byte = 1 pixel).
  21.  
  22. For clarity and consistancy with the rest of the class, it would be great
  23. if I could use regular array notation for this picture. For instance, if
  24. I want to just run through every pixel in the image, I'd like to say:
  25.  
  26. short i, j;
  27.  
  28. for (i=0;i<256;i++)
  29.   for (j=0;j<256;j++)
  30.     ProcessPixel(image[i][j]);
  31.  
  32. So my question is this: is it possible to allocate a bunch of memory using
  33. malloc() and then pretend it's a regular array?
  34.  
  35. I tried a bunch of type casting possibilities, but I couldn't come up
  36. with anything that worked. Seems like this is something I should know,
  37. but it's not.
  38.  
  39. E-mail is best, but I read here often too. Thanks for listening...
  40.  
  41. Caleb Strockbine
  42. cstrockb@ic.sunysb.edu
  43. --
  44. This message has been brought to you by the letters C and S and the number 3.
  45.