Thread: global array

  1. #16
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Unfortunately, I don't know the Matlab interface well enough to detemine how that works.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #17
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    would that work in c?
    EDIT:
    lets say i had
    Code:
    int foo(uInt8 *passed)
       uInt8 array[320*240];
       passed = array;
    return 0;
    Last edited by chico1st; 06-24-2008 at 09:43 AM.

  3. #18
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by chico1st View Post
    would that work in c?
    EDIT:
    lets say i had
    Code:
    int foo(uInt8 *passed)
       uInt8 array[320*240];
       passed = array;
    return 0;
    Sort of; passed would be a pointer to array. Unfortunately, once you hit return 0, that array ceases to exist, so now you have a pointer to nowhere in particular. You would need passed = malloc(320*240*sizeof(uInt8)) instead, since that malloc'ed memory will remain until you free it.

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    The type is wrong. This is 2D array, so the type would be uInt8 (*)[240].
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Noob : Creating a global array?
    By Swerve in forum C++ Programming
    Replies: 3
    Last Post: 06-07-2008, 10:38 AM
  2. Increase size of global multidimensional array
    By 3saul in forum C Programming
    Replies: 4
    Last Post: 04-22-2006, 09:00 PM
  3. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  4. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-11-2004, 11:15 PM
  5. Initilizing global array to all zeroes
    By Durafei in forum C++ Programming
    Replies: 3
    Last Post: 06-07-2003, 12:33 PM