Mail Archives: djgpp/1997/03/13/23:54:44
Paul Peavyhouse (pv AT cs DOT montana DOT edu) wrote:
: The funny thing is that if I write it as:
: DATAFILE *terra;
: int main (int c, char **v)
: {
: char *str;
: terra = load_datafile("terra.dat");
: }
: ...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!
I'll repeat this in case you had missed it amongst all the (incorrect)
posts about your printf statement: In C, you *must* define all variables
before any statements in a function. In C++ this is relaxed, and your
original code would be correct. If you want gcc to compile your code as
C++ code, make sure the file extension is .cc or .cpp, or call the
compiler with a capital .C, i.e.:
gcc myfile.C
Hope this helps.
--
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford
- Raw text -