C Programming Question and Answers

73. What is NULL in C?
  NULL is a macro which defined in C header files. The value of NULL macro is 0. It is defined in C header files as below
#define NULL (void *) 0;
NULL is used for pointers only as it is defined as (void *) 0. It should not be used other than pointers. If NULL is assigned to a pointer, then pointer is pointing to nothing.
 
Your Name Your Email-ID
Your Answer
74. What is null pointer in C?
  Null pointer is a pointer which is pointing to nothing. Null pointer points to empty location in memory. Value of null pointer is 0. We can make a pointer to point to null as below.
int * p = NULL;
char * p = NULL;
 
Your Name Your Email-ID
Your Answer
75. What happens when the user gives a command to run a program?
  The operating system first allocates the requisite amount of memory to the program, then, through loader, loads the program in the allocated memory, and then passes on the control to the program. The program runs the supervision of the operating system. When the program finishes its execution or some runtime errors occurs, the operating system removes the program from the memory.
 
Your Name Your Email-ID
Your Answer
76. What is file pointer in C?
 
  • File pointer is a pointer which is used to handle and keep track on the files being accessed.
  • A new data type called FILE is used to declare file pointer. This data type is defined in stdio.h file.
  • File pointer is declared as FILE *fp. Where, 'fb' is a file pointer.
  • fopen() function is used to open a file that returns a FILE pointer.
  • Once file is opened, file pointer can be used to perform I/O operations on the file. fclose() function is used to close the file.
 
Your Name Your Email-ID
Your Answer