Function in C

Programming, for all ages and all languages.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Function in C

Post by AndrewAPrice »

The advantages of floating point addresses, you could check to see if it's a NaN :)
My OS is Perception.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Function in C

Post by Solar »

Combuster wrote:that's why you should compare to NULL instead of comparing to 0. On machines without MMU you'll see often enough that RAM starts at 0 and the program is in ROM somewhere else. And then your code must still be able to work.
Ehm... actually, no. ;-)

The definition of a null pointer constant is "an integer constant expression with the value 0, or such an expression cast to type void *". ;-)
Every good solution is obvious once you've found it.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Function in C

Post by Creature »

Solar wrote:
Combuster wrote:that's why you should compare to NULL instead of comparing to 0. On machines without MMU you'll see often enough that RAM starts at 0 and the program is in ROM somewhere else. And then your code must still be able to work.
Ehm... actually, no. ;-)

The definition of a null pointer constant is "an integer constant expression with the value 0, or such an expression cast to type void *". ;-)
Yep, I believe in C, NULL is defined as

Code: Select all

#define NULL ((void *) 0) //or something equivalent.
whilst in C++ it's defined as (or should be defined as, if you use it, according to Bjarne Stroustrup):

Code: Select all

#define NULL 0
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Post Reply