www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/10/01:22:43

Message-ID: <34DFEA24.12C2@post.comstar.ru>
Date: Tue, 10 Feb 1998 09:20:54 +0300
From: Dim Zegebart <zager AT post DOT comstar DOT ru>
Reply-To: zager AT post DOT comstar DOT ru
Organization: Comstar Ltd.
MIME-Version: 1.0
To: Jason Alexander <jalex AT ea DOT oac DOT uci DOT edu>
CC: DJGPP Mail List <djgpp AT delorie DOT com>
Subject: Re: Dynamically declaring 2-d arrays
References: <34DF9744 DOT C7CFDBFE AT ea DOT oac DOT uci DOT edu>

Jason Alexander wrote:
> 
>   Can someone explain to me how to dynamically declare a 2-d array?
>   I know the following code works for dynamically declaring a 1-d array
> of integers, but I don't see how to extend it to the 2-d case.
> 
> int main(void) {
>  int i;
>  int *array;
> 
>  printf("Array dimension: ");
>  scanf("%d", &i);
>  array = (int *) malloc(i*sizeof(int))
> }
GCC has special feature which allows to declare arrays dynamically :
int foo(ibt x,int y)
{ int arr[x][y];
  ...
}
That's all.
Note, this is a specific gcc feature, so it's not portable to other
compilers.

-- 
____ ____ 
|   \   /   Dim Zegebart
____/____   

Moscow Russia
WWW - http://www.geocities.com/siliconvalley/pines/7817
DZcomm - comm library for Allegro
Palantir - multytasking kernel for Allegro (based on PDMLWP)

- Raw text -


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