Thread: help me..how to demostrate 3D array in 1D array prototye please

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    5

    help me..how to demostrate 3D array in 1D array prototye please

    write a function to give demostrate the functionality of 3d in 1d. function prototye:
    change(int value,int indexX,int indexY,int indexZ, int [] 1dArray);
    value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I'm pretty sure that prototype is illegal in C.

    You can simulate a 3D array with a 1D array provided you know how big the array is in each dimension (technically you don't need to know the size of x, but). Think about how a 3D array is stored in memory.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The only thing illegal with it is the location of the [].
    Code:
    void change( int v, int ix, int iy, int iz, int *a );

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    5
    but sir i am still not able to get even after the change what is to be done and how.please suggest

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What is your current code and corresponding errors?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Sep 2009
    Posts
    5
    plzzz tell me what does this actually mean

    "functionality of 3-d in 1-d"

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    The more z's you put in your posts, the less help you will actually get.

    And it means just what it says: the functionality of a 3-d array, but using a 1-d array to actually store things. (Or if you like: to re-interpret a 1-d array as actually rows, columns, etc of a 3-d grid. Have you bothered to look at how C stores a 3-d array in memory?)

  8. #8
    Registered User
    Join Date
    Sep 2009
    Posts
    5
    thanx guys...............now i got the answer............................

  9. #9
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Quote Originally Posted by tabstop View Post
    The more z's you put in your posts, the less help you will actually get.
    rotflol!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. 3D Array
    By Alextrons in forum Windows Programming
    Replies: 4
    Last Post: 01-11-2002, 01:39 AM
  4. 3d array
    By Pamela in forum C++ Programming
    Replies: 1
    Last Post: 10-24-2001, 03:59 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM