Computing.Net > Forums > Programming > Char pinter in c++

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Char pinter in c++

Reply to Message Icon

Original Message
Name: ismar
Date: December 5, 2005 at 11:11:35 Pacific
Subject: Char pinter in c++
OS: Windows xp
CPU/Ram: 2 GB
Comment:

I have some questions about char-pointers in c++. I have made a image


of what i THINK is happening when i write
char c[] = "hello";
char* c2= c;

and
char c = "hello";
char* c2= c;


Is this image correct? How can adress of "c" be the same as c[0] and c in the first image?

And why is "c2" pointing to "c[0]" and not to "c" in the last image?


Report Offensive Message For Removal


Response Number 1
Name: ismar
Date: December 5, 2005 at 11:22:25 Pacific
Reply: (edit)

Adress for the image i made is: http://www.slomic.no/char_pointers.gif


Report Offensive Follow Up For Removal

Response Number 2
Name: jntupal
Date: December 15, 2005 at 06:12:29 Pacific
Reply: (edit)

I think this is not the case in the C but may be in C++


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 7 Days.
Discuss in The Lounge
Poll History




Data Recovery Software