Thread: Two-dimensional array

  1. #1

    Two-dimensional array

    What is the right syntax for function prototype involved with a two-dimensional array?

  2. #2
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    void printArray(int array[][4]); /* declare function */
    now you can pass your 2d array to this function... also pass the size to be sure you're not accessing any un-owned memory.

  3. #3
    Registered User Dev's Avatar
    Join Date
    Mar 2003
    Or you can just pass the base address of the 2d array and number of rows and columns of that array.

    And then implement the logic to get to particular element in the array in your function.

  4. #4
    Registered User
    Join Date
    Apr 2003
    in one of my functions i create a 2 dimensional array getMessage[6][128] which is 6 lines of input going 128 characters across

    i then ask for a number to use as an encryption key

    then have to run this array through an encryption algorithm:
    encryptedcode= (i- 32 +key)%95 +32)

    then ask for the same number which will then decrypt the message.

    basically, i'm going to have to access an array i create in another function from another function. Will i need pointers to do this?

    void encode(char getMessage[][])
      int i;
        for (i = 0; i < getMessage[][]; i++)
            if (getMessage[i] != '\n')
                  getMessage[i] = (getMessage[i] - 32 +key)%95 +32);
                  getMessage[i] = 0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. two dimensional array
    By leisiminger in forum C Programming
    Replies: 12
    Last Post: 03-09-2008, 11:53 PM
  3. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM
  4. Replies: 5
    Last Post: 11-20-2001, 12:48 PM