what is the difference between NULL('\0') and 0?
Answers were Sorted based on User's Feedback
Answer / sri
null(\0) is used for strings,and there is difference
between \0 and 0.
Is This Answer Correct ? | 25 Yes | 1 No |
Answer / shani chaudhari
null(\0) is used for termination of string meance each and
every string ended with \0 while 0 is mostly related with
binary operations..null(\0) meance nothing but 0 has its own
value and existance. both are different
Is This Answer Correct ? | 11 Yes | 0 No |
Answer / guest
NULL('\0')- A string in C is always terminated by a null
character.The ascii value of '\0' is 0
0 - The ascii value of 0 is 48
Is This Answer Correct ? | 10 Yes | 3 No |
Answer / guest
ASCII value of 0 is 0,but ASCII value of '\0' is 27.
Is This Answer Correct ? | 22 Yes | 16 No |
Answer / salim
I am going to speak in cotext to c language.
NULL is a macro defined in header files such as
stdio.h,stdlib.h,alloc.h,stddef.h,mem.h.The c pre processor
substitutes NULL by the value 0.Its declaration appears to
be like #define NULL 0 in the standard libraries.It is
used to initialise pointers to 0 and helps in portability.
It is a null pointer constant a convention for programmers
to initialise pointers.It is used mainly with pointer.
0 is simply an integer constant.
/0 is a backslash character contant used to indicate end of
string or a string terminator.
Is This Answer Correct ? | 6 Yes | 0 No |
NULL is an the empty value but 0(zero) is an one of the value
Is This Answer Correct ? | 7 Yes | 4 No |
Answer / shashwat
Actually binary code of both are same.
0 -> 00000000 NULL
But when this 0 is included in a string or char as
char x = '0';
or char x[20] = "1230";
It is the character zero (not NULL). It has an ASCII of 48
and will be stored as
00110000.
That is why, they have created different zeroes to
represent either the character zero or ASCII value zero.
Is This Answer Correct ? | 1 Yes | 0 No |
What is the difference b/w '\0' and NULL?
The first is the representation for the null character, i.e.,
a character with value zero. It is used as a string
terminator in C.
It is actually an "escape sequence" with an octal zero.
The second is a macro that resolves to a null pointer value.
In C source
code a literal zero is also converted into a null pointer
constant when
it occurs in a pointer context.
The first expression is of type int while the second is of a
pointer
type.
> In which case It is useful?
Use '\0' to terminate strings and NULL to initialise
pointers and set
them to a "safe" value after they have been used.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / madhu
end of the string is indicated by \0 but 0 is a value
thus there is difference between them
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / mangal
The nul is used for the string so there is no any character
contain by null
but
The o is an intiger value an they have some meaning fot
that in intiger type
Is This Answer Correct ? | 0 Yes | 0 No |
What is macro?
What is a nested formula?
1) write a program to generate 1st n fibonacci prime numbers using Nested if 2) write a program to generate twin prime numbers from m to n using nested if 3) write a program to check whether a given integer is a strong number or not using nested if 4) Write a program to generate prime factors of a given integer using nested if 5)write a program to generate prime numbers from m to n using nested if 6)write a program to generate perfect numbers from m to n using nested if 7)write a program to generate the pallindromes from m to n using neste if 8)write a program to generate armstrong numbers from m to n using nested if 9)write a program to generate strong numbers from m to n using nested if
How can I allocate arrays or structures bigger than 64K?
What will be the result of the following program? main() { char p[]="String"; int x=0; if(p=="String") { printf("Pass 1"); if(p[sizeof(p)-2]=='g') printf("Pass 2"); else printf("Fail 2"); } else { printf("Fail 1"); if(p[sizeof(p)-2]=='g') printf("Pass 2"); else printf("Fail 2"); } } a) Pass 1, Pass 2 b) Fail 1, Fail 2 c) Pass 1, Fail 2 d) Fail 1, Pass 2 e) syntax error during compilation
main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }
#include<stdio.h> main() { int a[3]; int *I; a[0]=100;a[1]=200;a[2]=300; I=a; Printf(“%d\n”, ++*I); Printf(“%d\n”, *++I); Printf(“%d\n”, (*I)--); Printf(“%d\n”, *I); } what is the o/p a. 101,200,200,199 b. 200,201,201,100 c. 101,200,199,199 d. 200,300,200,100
What is a node in c?
will the program compile? int i; scanf(“%d”,i); printf(“%d”,i);
which will be first in c compiling ,linking or compiling ,debugging.
#define MAX 3 main() { printf("MAX = %d \n",MAX ); #undef MAX #ifdef MAX printf("Vector Institute”); #endif
How can I find leaf node with smallest level in a binary tree?