How pointer variables are initialized ?
There are 2 main ways to initialize pointer vaiables.These are:
1.Static Memory Allocation(SMA)
2.Dynamic Memory Allocation(DMA)
Some initialization of pointer variables are given below:
We can initialize pointer variables as datatype *VariableName(Declaration)
e.g. int *ptr,i;
It can be initialized as
2.We can also initialized pointer as:
3.Below I have given a eg for you. This example defines weekdays as an array of pointers to string constants.
static char *weekdays[ ] =
"Sun", "Mon", "Tue", "Wed",
"Thu", "Fri", "Sat"
How to print 1 to 100 without using any conditional loop?
There are 2 ways i have given you. Using these you can solve this problem.
DisplayInfo(Int num = 1)
Printf("%d ", num);
if(num == 100)
Constant volatile variable declaration is possible or not? if give any one example and reason.
yes, constant variable declaration is possible. Constants can be defined by placing the keyword const in front of any variable declaration. If the keyword volatile is placed after const, then this allows external routines to modify the variable.
Example: An input-only buffer for an external device could be declared as const volatile to make sure the compiler knows that the variable should not be changed and that its value may be altered by processes other than the current program.
Write a program with out using main() function?
No,we can write a program with out main function, this function is the main function which usually help OS to kill the process that has executed. Reply
Replied By: Name: Rajesh
What is the use of kbhit?
kbhit() defined in the header conio.h checks to see if a keystroke is currently available.
The available keystroke can be retrieved with getch() of getche();
It returns a non-zero value when there is a keystroke else it returns zero.
How to use floodfill() function ?
The main issue of making floodfill function is that it connect the connected pixels of an entire area with same color.It also called Bucket tool in all programming languages.
Keep one thing in mind FloodFill function has only compatibility with 16 bits operating system.You should use the ExtFloodFill function with FLOODFILLBORDER.
HDC hdc, // handle to DC
int nXStart, // starting x-coordinate
int nYStart, // starting y-coordinate
COLORREF crFill // fill color
hdc -> Handle to a device context.
crFill->Then area to be filled
What is difference between static and global static variable?
Main difference between static and global static variables are given below:
In context of memory it allocated to static variables only once.
Static global variable has scope only in the file in which they are declared. outside the file it can not be accessed. but its value remains intact if code is running in some other file Reply
Difference between arrays and pointers?
Arrays automatically allocate space with fixed in size and location,but in pointers above are dynamic.
array is refered directly to the elements.
but pointers refers to address of the elements. Reply
What is the purpose of realloc( )?
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.Reply
What is static memory allocation and dynamic memory allocation?
Information regarding static menmory allaocaion and dynamic memory allocation are given below:
Static memory allocation:
The compiler allocates the required memory space for a declared variable.Using the address of operator,the reserved address is obtained and assigned to a pointer variable.most of the declared variable have static memory,this way is called as static memory allocation.
In tis memory is assign during compile time.
Dynamic memory allocation:
For getting memory dynamically It uses functions such as malloc( ) or calloc( ).the values returned by these functions are assingned to pointer variables,This way is called as dynamic memory allocation.
In this memory is assined during run time.