Interview Questions

C/C++ Questions only (Pointers)

C++ programming on UNIX, C++ Networking,C++ Algorithm Questions and Answers


(Continued from previous question...)

C/C++ Questions only (Pointers)

1. What's wrong with "char *p; *p = malloc(10);"?

2. Does *p++ increment p, or what it points to?

3. I want to use a char * pointer to step over some ints. Why doesn't

"((int *)p)++;" work?

4. I have a function which accepts, and is supposed to initialize, a

pointer, but the pointer in the caller remains unchanged.

5. Can I use a void ** pointer to pass a generic pointer to a

function by reference?

6. I have a function which accepts a pointer to an int. How can I

pass a constant like 5 to it?

7. Does C even have ``pass by reference''?

8. I've seen different methods used for calling functions via

(Continued on next question...)

Other Interview Questions