|
|
Gail wrote:
> How often does a C/C++ programmer really need a function pointer?
Hopefully very rarely...
>> Which one is FALSE? Is that 0 or 1? I know it's one or the other, but
>> I can never ever remember which - and it's kind of important!
>
> 0. Any other value is true.
I remember that 0 is one thing and everything else is the opposite. But
I can never remember which is which.
>> What insane nutcase thought that making assignment an expression as a
>> good idea? Seriously, WTF? That's excellent. So if I say "if (x =
>> 5)..." then my program will silently fail to work correctly, and I'll
>> probably spend hours if not days trying to figure out why.
>
> Most compilers will warn about that these days.
> It's the same in Java, the same in C#
In Java, unless x happens to be a bool, you'll get a compile-time error.
In C it's a perfectly valid construct.
>> Pointers in general usually result in disaster. I constantly get the
>> syntax wrong for pointer types, pointer dereferencing, and pointer
>> creation.
>
> So don't use them. As Warp and others have shown, it's not necessary in
> any way to use pointers.
It is in C. If you want printf() to print a string for you, you must
pass a pointer to a string.
Maybe this is one of the things they actually fixed in C++...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|