From: Phred Phungus on
glen herrmannsfeldt wrote:

> C99 does allow dynamic sized automatic arrays, unlike C89,
> so adding this makes some sense.
>
> #include <stdio.h>
> // test variable dimension dummy arrays
> int main() {
> int n=5;
> float y[5][5];
> fun(&n,y);
> }
> int fun(int *n,float x[*n][*n]) {
> printf("%d %f\n",*n,x[3][3]);
> }
>
> Works with my version of gcc.

[snipping a lot of stuff I don't understand]

Is this working?

$ gcc -D_GNU_SOURCE -std=c99 -Wall -Wextra g1.c -o out
g1.c: In function �fun�:
g1.c:7: warning: control reaches end of non-void function
$ ./out
5 0.000000
$ cat g1.c


#include <stdio.h>

int fun(int *n,float x[*n][*n]) {
printf("%d %f\n",*n,x[3][3]);
}


// test variable dimension dummy arrays
int main() {
int n=5;
float y[5][5];
fun(&n,y);

return 0;
}

// gcc -D_GNU_SOURCE -std=c99 -Wall -Wextra g1.c -o out
$

I might be like others who read clf and see Richard write of something
that looks like Thanks In Advance. Apparently, it's a mini-stroke:

http://en.wikipedia.org/wiki/Transient_ischemic_attack

I'm certain we all hope for complete convalescense.
--
fred
From: Les Neilson on

"Gib Bogle" <g.bogle(a)auckland.no.spam.ac.nz> wrote in message
news:hn4jdu$7jj$1(a)speranza.aioe.org...
> Richard Maine wrote:
>> glen herrmannsfeldt <gah(a)ugcs.caltech.edu> wrote:
>>
>>> Do remember the different subscript
>>> order betweeen Fortran and C.
>>
>> Oops. Yes, I knew that. But I forgot to account for it when I gave the
>> Fortran version of the dimensions.
>>
>> Wonder if I can blame it on the apparent TIA I had last Friday (about
>> 10-15 minutes of memories just aren't there - not even a hint of them).
>> :-(
>>
>
> 15 minutes? I have whole years missing. ;-)

If they're from the 1960's that is only to be expected :-)

Les

PS
Keep well Richard

First  |  Prev  | 
Pages: 1 2 3
Prev: The perpetual calendar
Next: Flowchart software