Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.20/5 (5 votes)
See more:
Please explain these to me:
1. Difference between void pointer and Null pointer.
2. Why Null pointer is necessary?
3. Difference between malloc() and calloc().
4. Purpose of "extern" keyword

Thanks in advance!
Posted
Updated 30-Mar-11 3:22am
v4
Comments
Manfred Rudolf Bihy 30-Mar-11 9:22am    
You've not by any chance had an interview today?
Olivier Levrey 30-Mar-11 9:34am    
My vote of 2. How many questions are you going to ask on all C/C++ basics???
Go ahead, search the web, read books!
Sandeep Mewara 30-Mar-11 9:35am    
No effort.

(1) void is a type, NULL is a value.
(2) Why the empty set is necessary in set theory?
(3) calloc initializes (with zeroes) allocated memory while malloc doesn't.
(4) extern is used:
- to declare a variable defined in another source file (e.g. extern int g_instance_count; ).
- to notify the C++ compiler that some code is C (e.g. extern "C" {/* C functions here */ }).
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 30-Mar-11 16:36pm    
Of course, this Answer is too advanced to the one who voted "3".
I think this Answer is excellent; I especially like (2).
5++++++
--SA
CPallini 30-Mar-11 16:47pm    
I should know that. Thank you, sir. :-)
Sergey Alexandrovich Kryukov 30-Mar-11 16:36pm    
Recommended as Answer. It's the best one so far.
--SA
1. Difference between void pointer and Null pointer.
 void* is a type of pointer but NULL is a value that any pointer can assume.

2. Why Null pointer is necessary?
 NULL is normally used to indicate that the pointer doesn't point to anything.
 
Share this answer
 
extern key word is used to provide linkage.
 
Share this answer
 
Comments
UL UL ALBAB 30-Mar-11 10:00am    
I need example...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900