Re: K&r chapter-1; exc-17
From: Dan Pop (Dan.Pop_at_cern.ch)
Date: 11/30/04
- Next message: Xenos: "Re: fseek past the eof"
- Previous message: Xenos: "Re: fseek past the eof"
- In reply to: Merrill & Michele: "Re: K&r chapter-1; exc-17"
- Next in thread: Merrill & Michele: "Re: K&r chapter-1; exc-17"
- Reply: Merrill & Michele: "Re: K&r chapter-1; exc-17"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Nov 2004 15:32:30 GMT
In <tuidnTpfWOBY7jrcRVn-pQ@comcast.com> "Merrill & Michele" <beckjensen@comcast.net> writes:
>> "Dan Pop"
>>
>> It is not the first time you're making this mistake. I didn't work in
>> the past, I doesn't work now and it is highly unlikely that it will work
>> in a future version of the language.
>
>I posted something downthread that I thought worked. Did I stumble into
>non-ANSI/ISO or undefined behavior?
Into something standard C doesn't allow. I'm too lazy to check whether
it's a syntax rule or constraint violation, but it doesn't make any
practical difference, anyway.
>> If you didn't try to improve on the K&R bracing and spacing style,
>> it would have been even more obvious that you're attempting to *define*
>> getline() *inside* main(). You CANNOT do that in C.
>
>No, I just blew the close-brace.
Which, from the compiler's point of view, is undistinguishable from
defining getline() inside main().
>It's also on my short list to write a prog
>that counts open and close braces, but I've only got 32 hours in a day. MPJ
As I said in my previous message, a better bracing style would have made
your mistake glaringly obvious without having to count anything at all.
Compare:
int main()
{
int foo;
...
return 0;
}
int getline()
{
and
int main()
{
int foo;
...
return 0;
int getline()
{
The misalignment between the return statement and the line starting the
definition of the new function is a strong visual clue that something is
wrong: there *must* be a missing closing brace in between.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de
Currently looking for a job in the European Union
- Next message: Xenos: "Re: fseek past the eof"
- Previous message: Xenos: "Re: fseek past the eof"
- In reply to: Merrill & Michele: "Re: K&r chapter-1; exc-17"
- Next in thread: Merrill & Michele: "Re: K&r chapter-1; exc-17"
- Reply: Merrill & Michele: "Re: K&r chapter-1; exc-17"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|