Click here to Skip to main content
15,925,255 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: ACL Pin
David Crow30-May-07 6:12
David Crow30-May-07 6:12 
AnswerRe: ACL Pin
Hamid_RT30-May-07 8:52
Hamid_RT30-May-07 8:52 
QuestionSetup Maker Pin
garfield18530-May-07 1:47
garfield18530-May-07 1:47 
AnswerRe: Setup Maker Pin
Hamid_RT30-May-07 2:28
Hamid_RT30-May-07 2:28 
QuestionSimple pointer question... Pin
Haroon Sarwar30-May-07 1:32
Haroon Sarwar30-May-07 1:32 
AnswerRe: Simple pointer question... [modified] Pin
Nibu babu thomas30-May-07 1:49
Nibu babu thomas30-May-07 1:49 
AnswerRe: Simple pointer question... Pin
CPallini30-May-07 2:11
mveCPallini30-May-07 2:11 
AnswerRe: Simple pointer question... Pin
Matthew Faithfull30-May-07 2:20
Matthew Faithfull30-May-07 2:20 
If you do these within a function they will both get allocated on the Stack, one array and one pointer. The actual "Hello" text in each case will end up as static data within the executable image. char text[] = "Hello"; will give you an on stack copy of this data at runtime. const char* test = "Hello"; will give you a pointer to the string stored in the image memory. char* test = "Hello"; will almost certainly be the same.
If you do these at file scope, i.e. in a .c or .cpp file but not in a function then the "Hello" text is still stored in the image and in this case so is test[] or test. With a reasonable optimising compiler with string merging char* test; will probably end up pointing to the same memory refered to by char test[] which will be the one and only original "Hello" text in the loaded image.

Have a look in the debugger at runtime and see what the address values are in each case. You'll soon spot the pointers to stack memory as opposed to pointers into the loaded image, the ranges will be quite different.Smile | :)

Nothing is exactly what it seems but everything with seems can be unpicked.

AnswerRe: Simple pointer question... Pin
David Crow31-May-07 3:32
David Crow31-May-07 3:32 
QuestionAgain CListCtrl Pin
Bravoone_200630-May-07 1:01
Bravoone_200630-May-07 1:01 
AnswerRe: Again CListCtrl Pin
Naveen30-May-07 1:05
Naveen30-May-07 1:05 
QuestionRe: Again CListCtrl Pin
Bravoone_200630-May-07 1:08
Bravoone_200630-May-07 1:08 
AnswerRe: Again CListCtrl Pin
Naveen30-May-07 1:13
Naveen30-May-07 1:13 
GeneralRe: Again CListCtrl Pin
Bravoone_200630-May-07 1:16
Bravoone_200630-May-07 1:16 
GeneralRe: Again CListCtrl Pin
Naveen30-May-07 1:22
Naveen30-May-07 1:22 
QuestionRe: Again CListCtrl Pin
Bravoone_200630-May-07 1:30
Bravoone_200630-May-07 1:30 
QuestionRe: Again CListCtrl Pin
Bravoone_200630-May-07 1:42
Bravoone_200630-May-07 1:42 
AnswerRe: Again CListCtrl Pin
Hamid_RT30-May-07 2:24
Hamid_RT30-May-07 2:24 
AnswerRe: Again CListCtrl [modified] Pin
#realJSOP30-May-07 3:10
professional#realJSOP30-May-07 3:10 
QuestionRe: Again CListCtrl Pin
David Crow30-May-07 3:58
David Crow30-May-07 3:58 
AnswerRe: Again CListCtrl Pin
#realJSOP30-May-07 4:23
professional#realJSOP30-May-07 4:23 
GeneralRe: Again CListCtrl Pin
David Crow30-May-07 4:29
David Crow30-May-07 4:29 
GeneralRe: Again CListCtrl Pin
#realJSOP30-May-07 4:36
professional#realJSOP30-May-07 4:36 
GeneralRe: Again CListCtrl Pin
Hamid_RT30-May-07 8:49
Hamid_RT30-May-07 8:49 
AnswerRe: Again CListCtrl Pin
Naveen30-May-07 14:16
Naveen30-May-07 14:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.