Mail Archives: djgpp/1997/03/14/09:44:07
Actually ANSI "C" permits the declaration of variables at the beginning
of any code block, ie after the opening brace ({) and before any
executable code.
Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com
On 13 Mar 1997, John Beppu wrote:
> In article <5g9p1b$fac AT netra DOT montana DOT edu>,
> Paul Peavyhouse <pv AT cs DOT montana DOT edu> wrote:
>
> [this didn't work for Paul]
>
> >DATAFILE *terra;
> >
> > int main (int c, char **v)
> > {
> > terra = load_datafile("terra.dat");
> > char *str;
> > }
> >
>
> [but this one did work for Paul]
>
> >
> >DATAFILE *terra;
> >
> > int main (int c, char **v)
> > {
> > char *str;
> > terra = load_datafile("terra.dat");
> > }
> >
> Maybe you've found another difference between C and C++. In C,
> variables need to be declared at the beginning of a function;
> with C++, this isn't the case. Did you compile these as C
> programs when you really meant to compile them as C++ programs?
> What error messages did you receive?
>
>
>
> > ...IT WORKS?!?!?! I can live with writing it this way, but I want to
> >know why the compiler pukes when I write it the other way. Can any help me
> >here? I'd appreciate it!
>
> [daydreaming]
>
> (I wish comp.lang.asm.x86 would be liberated... I miss it.)
>
>
>
>
> --
> beppu AT uci DOT edu .............................................................
>
- Raw text -