Re: Multidimensional array problems
From: Al Bowers (xabowers_at_rapidsys.com)
Date: 04/05/04
- Next message: Malcolm: "Re: justification check"
- Previous message: Joona I Palaste: "Re: How can we use functions setwindow,scrollwindowup and scrollwindown"
- In reply to: Jimmy Petersen: "Multidimensional array problems"
- Next in thread: Emmanuel Delahaye: "Re: Multidimensional array problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 05 Apr 2004 15:48:59 -0400
Jimmy Petersen wrote:
> Hello all,
>
> After reading through chapter 6 of the faq I must admit
> I'm a bit confused :-).
>
> What I am trying to do can be explained with the following
> three sample files:
>
> var.c:
> float a[2][2] = {{1.0f, 2.0f},{3.0f, 4.0f}};
>
> var.h:
> #ifndef var_h
> #define var_h
>
> extern float a**;
>
> #endif
>
> test.c
> #include "var.h"
> #include <stdio.h>
>
> int main() {
> printf("a[0][0] = %f\n", a[0][0]);
> return(0);
> }
>
> This doesn't appear to be working though since the compiler (gcc)
> reports "'a' undeclared". I know from the faq that arrays and
> pointers are not the same but after having tried declaring 'a' as
> 'extern float* a[];' and 'extern float a[][];' I've found that
> the only thing which compiles is 'extern float* a[];' but this
> only gives me an array of pointers to unallocated memory.
>
> How do I do the two-dimensional thing?
>
Change, in var.h
extern float **a;
to
extern float a[2][2];
-- Al Bowers Tampa, Fl USA mailto: xabowers@myrapidsys.com (remove the x to send email) http://www.geocities.com/abowers822/
- Next message: Malcolm: "Re: justification check"
- Previous message: Joona I Palaste: "Re: How can we use functions setwindow,scrollwindowup and scrollwindown"
- In reply to: Jimmy Petersen: "Multidimensional array problems"
- Next in thread: Emmanuel Delahaye: "Re: Multidimensional array problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|