English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

represent False a: the null pointer B:a floating expression haveing the value 0.0 C: the null character '\0' D: all of the above.

2007-03-20 05:58:37 · 4 answers · asked by taylor_boswell 1 in Computers & Internet Programming & Design

4 answers

Sure - let's take 'em all. The answer is D.

(C WILL TREAT NULLS AS FALSE. Period. Perhaps someone is thinking of SQL and other languages where NULL != 0, but that's NOT the case in C.)

Null pointers are often returned from functions indicating failure. Thus, null pointers can be tested as false.

Null character '\0' ( 00 000 000) itself is zero and will equate to false.

Value of 0, whether 0.0 as a double or float, int, short, long, etc, is still zero and will equate to false.

Have a look with this program:
#include

int main() {

char myChar='\0';
double myDouble=0.0;
char * myPtr = NULL;

if ( ! myChar )
printf ("NOT MyChar - FALSE\n");
else
printf ("myChar - TRUE\n");

if ( ! myDouble )
printf ("NOT myDouble - FALSE\n");
else
printf ("myDouble - TRUE\n");

if ( ! myPtr )
printf ("NOT myPtr - FALSE\n");
else
printf ("myPtr - TRUE\n");
}
"testit.c" 27 lines, 367 characters
reznet1__/disc12/users/resnimi-> make testit
cc -O testit.c -o testit
reznet1__/disc12/users/resnimi-> ./testit
NOT MyChar - FALSE
NOT myDouble - FALSE
NOT myPtr - FALSE

2007-03-20 06:06:55 · answer #1 · answered by BigRez 6 · 1 0

B. All of the other answers include NULL. Null doesn't have a value. Null != 0. Always remember that. Even a floating expression with a value of 0 will be 0. NULLS are not 0.

2007-03-20 06:05:36 · answer #2 · answered by Joe M 3 · 0 2

its B. the null value refers to empty meaning no value at all so it cannot be equal to zero. and the only B can be used to represent false is if you typecast it to int since int and float have different memory allocations

2007-03-20 06:09:41 · answer #3 · answered by darknight83 2 · 0 2

permit's see. First my tongue out meaning i don't care approximately fundies. Then an evil snigger just to tease 'em some extra. Then s a grin to teach that I welcome absolutely everyone regardless of their (non) faith, then licking my lips to teach that I have no problem with pre-marital intercourse.

2016-11-27 00:50:53 · answer #4 · answered by ? 4 · 0 0

fedest.com, questions and answers