-
Can you explain me...??
can you explain one primitive thing ???
i dont understand this:
Code:
char * cp;
cp = "Ahoj";
?? when i want to create a pointer to int's array, i write : int * iP[10], but when i want to create char's array (string), i use char * cP only. I hope that what i said here is right......o:)
-
When you put "sggrs" (or any other constant string) into your source, it is put as part of the final .EXE file in a static buffer. This means that:
Code:
char *pcStr; // Pointer variable
pcStr = "hello"; // Assign to static variable in memory
The compiler doesn't need to allocate any extra memory for it, since it's already there.
-
int * iP[10]
is an array of pointers to ints. while
int * iP = new int[10]
is a pointer to a int array.
-
Quote:
Originally posted by parksie
Code:
char *pcStr; // Pointer variable
pcStr = "hello"; // Assign to static variable in memory
Can i change this later, or is pcStr constant?
-
You can change pcStr, but then you lose the pointer to that data. It's not a memory leak because it's static data anyway.