delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/09/22:00:24

From: "clint.allen" <clint DOT allen AT mci2000 DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Passing multidimentional arrays
Lines: 41
Message-ID: <3vep1.1610$e36.27573@news.mci2000.com>
Date: Fri, 10 Jul 1998 01:54:07 GMT
NNTP-Posting-Host: 166.55.3.146
NNTP-Posting-Date: Fri, 10 Jul 1998 01:54:07 GMT
Organization: MCI2000
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I don't quite understand how to pass multidimentional arrays to a function.
I am using two-dimentional arrays right now.  I read somewhere that you must
specify the column subscript, but not the row subscript.  The problem is, I
have several arrays (or tables) of different sizes, and I'm trying to pass
them to a lookup function.
For example:

float table_lookup(float table[][], float reference)
{
    float tableValue
    int stop, pointer, xRef, yRef;
    for (stop = 0, pointer = 1; stop != 1; pointer++)
    {
        if (reference == table[pointer][0])
        {
        yRef = pointer;
        stop = 1;
        }
    }
    for (stop = 0, pointer = 1; stop != 1; pointer++)
    {
        if (reference == table[0][pointer])
        {
        xRef = pointer;
        stop = 1;
        }
    }
    return tableValue[yRef][xRef];
}

When I compile this it gives me the error: "Arithmetic on pointer to an
incomplete type".  I know that "float table[][]" is wrong, but I don't know
what to put here.
Can anybody help?
----------------------
Clint Allen
clint DOT allen AT mci2000 DOT com
ICQ UIN: 8662422



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019