why to assign a pointer to null sometimes??how can a pointer
we declare get assigned with a garbage value by default???



why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbag..

Answer / Kavita Ranjhia

In C programming, pointers are used to store memory addresses. Assigning a pointer to NULL ensures that it does not point to any valid memory location. This is important for preventing undefined behavior or accessing invalid memory. By default, when you declare a pointer but do not initialize it, it may contain garbage values (i.e., random and unpredictable memory addresses).

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+zap(n-1); } then the call zap(6) gives the values of zap [a] 8 [b] 9 [c] 6 [d] 12 [e] 15

10 Answers   Wipro,


Explain the difference between struct and union.

2 Answers  


write a progrmm in c language take user interface generate table using for loop?

0 Answers  


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1 Answers   CLG,


int a=20; int b=30; int c=40; printf("%d%d%d"); what will be the output?

5 Answers   CMC,


Write a program to find given number is even or odd without using any control statement.

2 Answers  


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

1 Answers   Subex,


How do I swap bytes?

1 Answers  


Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.

6 Answers  


find out largest elemant of diagonalmatrix

1 Answers  


second highest number in a given set of numbers

3 Answers   TCS,


how we do lcm of two no using c simple if while or for statement

1 Answers  


Categories