[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] hvor er NULL lige defineret



On Fri, 21 Nov 2003 17:28:30 +0100
"Kasper Bonne" <sslug@sslug> wrote:

> NULL er defineret ved
> #define NULL (void*)0
> 
> NULL er altså en pointer, men *m (contents of m) er sikkert en integer, eller
> hvad.
Det er nemlig rigtigt, den klassiske lyn-kopiering af en string
kræver while ((*t++ = *s++) != 0)

Men her er lidt mere om NULL:

På min Linux (RH72/3) er det i
/usr/include/linux/stddef.h
#undef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif

Grunden til, at C++ har #define NULL 0
er at det alligevel ikke er tilladt at lave 

  char * charptr;
  void * voidptr = 0;
  charptr = voidptr

uden at caste i C++
helloptr.c: In function `int main(int, char**)':
helloptr.c:11: error: invalid conversion from `void*' to `char*'

med cast

  charptr = (char*)voidptr;

klager C++ ikke, heldigvis.



-- 
sslug@sslug -- http://d-axel.dk/


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:10 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *