|
-
Jun 10th, 2001, 01:41 PM
#1
Thread Starter
Member
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
-
Jun 10th, 2001, 04:07 PM
#2
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 11th, 2001, 05:02 PM
#3
transcendental analytic
int * iP[10]
is an array of pointers to ints. while
int * iP = new int[10]
is a pointer to a int array.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 11th, 2001, 08:00 PM
#4
Fanatic Member
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?
Alcohol & calculus don't mix.
Never drink & derive.
-
Jun 12th, 2001, 06:29 AM
#5
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|