Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Need help with C Pointers

Name: Anonymous 2008-10-15 22:47

why yes i am a fucking noob but you were too at one point, so please help me. basically, i'm trying to have a function

void foo(float * bar[][]) {code}

that receives a two-dimensional array of pointers, and later call the method by saying
foo(&array1);

the compiler just gives me
warning: passing argument 1 of 'foo' from incompatible pointer type

somebody please help me

Name: Anonymous 2008-10-15 23:02

is array1 a float **?

Name: Anonymous 2008-10-15 23:15

yeah, an array of arrays of floats.

Name: Anonymous 2008-10-15 23:43

yeah
an array of arrays of floats
Make up your mind already.  It can't be both.

Name: Anonymous 2008-10-15 23:45

it's a float[][]
a 2D array of floats
my mind is made up
sorry for confusing you

Name: Anonymous 2008-10-15 23:47

it's been a while since i've tried, but i'm fairly sure you can't pass in a 2d array using the array[][] syntax.

it'd have to be void foo(float*** bar){/*stuff*/}

Name: Anonymous 2008-10-15 23:53

You can only omit the first dimension of the array, otherwise you have to do the calculations for which spot you're trying to access yourself and just adjust the pointer to there.

Name: Anonymous 2008-10-16 0:20

try this:


void foo(float * bar[11][12]) {code}

...

float bar[11][12];

Name: Anonymous 2008-10-16 0:36

turn off compiler warnings

Name: Anonymous 2008-10-16 2:05

When you are passing it in are you passing the array or the pointer? Arrays are basically just pointers to the first variable in it so make sure you're passing the array's pointer and not one of it's pointers.

Also as I mentioned before, only the FIRST dimension of the array can be omitted. i.e. void foo(float * bar[][2]) {code}

Name: Anonymous 2009-03-06 6:10

Xs to SICP so   this might not   have names but   that doesnt make   anything aparent the   only thing that   only exists under   Net or does   it work on   all Unices Use?

Name: Anonymous 2009-07-12 7:06

me if the numerous. are for royalty, EXPERT PROGRAMMER ±±  him. inflating

Name: Anonymous 2011-02-03 6:38

Don't change these.
Name: Email:
Entire Thread Thread List