Click here to Skip to main content
16,005,091 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionACL Pin
vivekphlp30-May-07 2:07
vivekphlp30-May-07 2:07 
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 
There are notable differences between:

Haroon Sarwar wrote:
char test[] = "Hello";

Here test is a character array(i.e. a const pointer to a memory area containing six characters -remember the '\0' string terminator-), initialized with the string literal "Hello" .


Haroon Sarwar wrote:
char* test = "Hello";

Here test is a pointer to the string literal "Hello", that is a read-only memory area.

See the following sample code:

char test1[] = "Hello";
char * test2 = "Hello";

test1[2]='p'; //  (1) legal, you can change the value of an element of the array
// test1 = test2; (2) ILLEGAL, compiler error, test1 is a const pointer

//test2[2]='p';   (3) ILLEGAL, runtime error, you cannot change read-only memory area
test2 = test1;//  (4) legal, you can change the pointer value
test2[2]='p'; //  (5) legal, since now, test2 points to the same writable memory area of test1


Hope that helps

Smile | :)




If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

AnswerRe: Simple pointer question... Pin
Matthew Faithfull30-May-07 2:20
Matthew Faithfull30-May-07 2:20 
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 

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.