Quantcast
Channel: '\0' evaluates false, "\0" evaluates true - Stack Overflow
Viewing all articles
Browse latest Browse all 10

Answer by Bhartendu Kumar for '\0' evaluates false, "\0" evaluates true

$
0
0

The simple thing is ATLEAST 0 (int) and 0.0 (float or double) have FALSE value in C.

'\0' is integer 0.

"\0" is an array of characters. It does not matter that INSIDE the array how many Characters are there or what are those characters.

So, '\0' evaluates to 0 like 77-77 evaluates to 0.And 0 is false.

int x;x = '\0';printf("X has a value : %d");Output:


x has a value : 0

And the code:

if(0){printf("true");}else{printf("false");}

Output:


false


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>