- Declare a pointer called fnc which points to a function that returns an unsigned long.
unsigned long (*fnc)();
- Declare a pointer called pfnc which points to a function that returns a pointer to a structure of type nameAddr.
struct nameAddr *(*pfnc)();
- It is possible for a function to return a character, an integer, and a floating point number. Is it possible for a function to return a structure? Another function?
No. However, it is possible to return pointers to structures and functions.
- What is the difference between an lvalue and an rvalue?
The lvalue refers to the left-hand side of an assignment expression. It must always evaluate to a memory location. The rvalue represents the right-hand side of an assignment expression; it may have any meaningful combination of variables and constants.
- Given the decimal number 27, how would one express it as a hexadecimal number in C?
0x1B
- What is malloc()?
This function allocates heap storage for dynamic data structures.
- What is the difference between malloc() and calloc()?
The malloc() function allocates raw memory given a size in bytes. On the other hand, calloc() clears the requested memory to zeros before return a pointer to it. (It can also compute the request size given the size of the base data structure and the number of them desired.)
- What kind of problems was C designed to solve?
C was designed to be a "universal" assembly language. It is used for producing system software such as operation systems, compilers/interpreters, device drivers, editors, DBMS's and similar things. It is not as well suited to application programs.
9.Declare a void pointer
void *ptr;
10.Make the pointer aligned to a 4 byte boundary in a efficient manner
assign the pointer to a long number and the number with 11...1100 add 4 to the number
Thursday, 26 May 2011
C program part8
Labels:
C,
Interview question
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment