GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  C

 Print  |  
Question:  Why don\'t we add null pointer at the end of array of integer?How can we calculate the length of array of integer?



February 02, 2006 10:49:52 #5
 Michael Fitzpatrick Microsoft Expert  Member Since: February 2006    Total Comments: 5 

RE: Why don't we add null pointer at the end of array...
 

NULL is never added to any array since NULL is a pointer value. Typically it is

#define NULL (void*(0))

THere is no way to get the size of an array unless it is statically allocated and the header that includes it defines the size or it is in the same module.

HEADER.H

extern int a[];

CCODE.C

int n = sizeof(a);  // Returns n = 4 (pointer size)

int b[10];

int m= sizeof(b); // Returns m= 10 * sizeof(int)

     

 

Back To Question