Difficulty in NULL concept in C?
NULL in C programming can anyone tell me how NULL is handled in C?And the output of this program is 3, how with NULL concept?#include <stdio.h>int main(void) { int i; static int count; for(i =...
View ArticleAnswer by ChrisF for Difficulty in NULL concept in C?
NULL is should be synonymous with 0. It's more correctly used to indicate a null pointer.In this case the code will actually be:for (i = 0; i <= 5){ count++; i += 2;}
View ArticleAnswer by Larry Osterman for Difficulty in NULL concept in C?
For C, "NULL" is traditionally defined to be (void *)0 - in other words, it's a pointer alias to address 0. For C++, "NULL" is typically defined to be "0". The problem with NULL in C++ and C is that...
View ArticleAnswer by zneak for Difficulty in NULL concept in C?
NULL has most of its meaning when dealing with pointers. When dealing with integers, you would be better off using simply zero.Strictly speaking, NULL is simply the value zero with a fancy name, but...
View ArticleAnswer by Starkey for Difficulty in NULL concept in C?
NULL is defined as 0 by C. In your program, it counts from 0 to 5 (counting every 2nd number). That's why count is 3 (i = 0, 2, 4).NULL shouldn't be used this way. NULL should be used with pointers.
View ArticleAnswer by msw for Difficulty in NULL concept in C?
NULL is just a macro defined in stdio.h or a file that stdio includes. It can variously be defined as some variation of zero.If you run your code through the C pre-processor (usually cc -E) you can see...
View ArticleAnswer by pmg for Difficulty in NULL concept in C?
The type of NULL and the type of i are different, but C forgives you :)C is (mostly) not a "type-safe" language. I mean: it lets you mix types which other languages would complain.With C you can add...
View ArticleAnswer by dmckee --- ex-moderator kitten for Difficulty in NULL concept in C?
Don't confuse the idea of a NULL pointer in c with that of a nullable type or quantities in some dynamic languages. There are similar, but have distinct uses and meaning.In c the concept of NULL is...
View ArticleAnswer by Jens for Difficulty in NULL concept in C?
There's a whole chapter devoted to the Null pointer in the C FAQ that should answer all your questions.5.1 What is this infamous null pointer, anyway?5.2 How do I get a null pointer in my programs?5.3...
View Article