C Interviews
C Interview
const char*p - p is pointer to the constant character. i.e value in that address location is constant. const char* const p - p is the constant pointer which points to the constant string, both value and address are constants.
Realloc(ptr,n) function uses two arguments. ? The first argument ptr is a pointer to a block of memory for which the size is to be altered. ? The second argument n specifies the new size.The size may be increased or decreased.
A pointer value is a data object that refers to a memory location. Each memory location is numbered in the memory. The number attached to a memory location is called the address of the location
? New initializes the allocated memory by calling the constructor. Memory allocated with new should be released with delete. ? Malloc allocates uninitialized memory. ? The allocated memory has to be released with free.new automatically calls the constructor while malloc(dosen?t)
A recursion function is one which calls itself either directly or indirectly it must halt at a definite point to avoid infinite recursion.
? An array holds elements that have the same data type. Array elements are stored in subsequent memory locations Two-dimensional array elements are stored row by row in subsequent memory locations. Array name represents the address of the starting element
For executing a set of statements fixed number of times we use for loop while when the number of iterations to be performed is not known in advance we use while loop.
Compiler allocates memory space for a declared variable. By using the address of operator,the reserved address is obtained and this address is assigned to a pointer variable. This way of assigning pointer value to a pointer variable at compilation time is known as static memory allocation.
c++ ia an object oriented programing but c is a procedure oriented programing.c is super set of c++. c can't suport inheritance,function overloading, method overloading etc. but c++ can do this.In c-programe the main function could not return a value but in the c++ the main function shuld return a value.
NULL pointer is a pointer which is pointing to nothing. Examples : int *ptr=(char *)0; float *ptr=(float *)0;