Thread: arrays in function prototypes

  1. #16
    Registered User sentienttoaster's Avatar
    Join Date
    Nov 2002
    Posts
    79
    ok, I think I'm getting this, here are some quick questions. how would I pass the array in the prototype before main, if it hasn't been declared yet, and I would like to understand how why I only put a dimension in the second [] of my 2 dimension array while leaving the forst one empty. just some simple answers are needed, please don't think I am extremely stuped.
    This has been a public service announcement from GOD.

    111 1111

  2. #17
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Size information about the array is not passed along with the array. You can have the dimension on the end, presumably because it then has the appearance of passing an array of pointers (the compiler never sees them as arrays), but the following are all just as good since the compiler only sees the pointers, anyways:

    Code:
    void f(char[][16]);
    void f(char[][]);
    void f(char**);
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #18
    Registered User sentienttoaster's Avatar
    Join Date
    Nov 2002
    Posts
    79
    I think I can get it from here, Thanks to everyone who helped, despite the low levelness of the questions.
    This has been a public service announcement from GOD.

    111 1111

  4. #19
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> how would I pass the array in the prototype before main

    The prototype doesn't need the actual data, it just need to know what to do when the data enters.

    >> why I only put a dimension in the second [] of my 2 dimension array while leaving the forst one empty

    You can put both, if you care to:

    Code:
    void manipulate(char array[10][10])
    {
     array[0][0] = 0;
    }
    
    
    int main()
    {
     char x[10][10];
     
     manipulate(x);
    
     return 0;
    }
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM