c++ - Difference between initializing a C-style string to NULL vs. the empty string -
c++ - Difference between initializing a C-style string to NULL vs. the empty string -
are these 3 equivalent:
char* p= null; char* q = ""; char r[] = {'\0'};
i suspect first 1 different rest, i'm not exclusively sure.
char* p = null;
this assigns null pointer p
means p
not point valid memory address.
char* q = ""; char r[] = {'\0'};
these both create empty strings , equivalent. q
points valid memory address, unlike p
in previous example. r
array empty string.
c++ c string
Comments
Post a Comment