Jump to content
  • Advertisement
Sign in to follow this  
derek7

char c[] = "12345678"

This topic is 4442 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
The compiler creates a place in memory with "123456789\0" not "1234567890" and points c to it.

But I can say that "c" is probably not assigned 12345678, it is given a memory address.

Share this post


Link to post
Share on other sites
Quote:
Original post by Boder
The compiler creates a place in memory with "123456789\0" not "1234567890" and points c to it.

But I can say that "c" is probably not assigned 12345678, it is given a memory address.


all char is number. so '\0\ is exact equal to 0. maybe I wrong.but it often confuse people. I thing \0 is exact a number it is 0.

Share this post


Link to post
Share on other sites
Quote:
Original post by derek7
Quote:
Original post by Boder
The compiler creates a place in memory with "123456789\0" not "1234567890" and points c to it.

But I can say that "c" is probably not assigned 12345678, it is given a memory address.


all char is number. so '\0\ is exact equal to 0. maybe I wrong.but it often confuse people. I thing \0 is exact a number it is 0.
Yes, \0 equals ASCII 0, but ASCII 0 does not equal '0'. That's got a code of 48 or something (Don't know the number off the top of my head)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Boder
The compiler creates a place in memory with "123456789\0" not "1234567890" and points c to it.

But I can say that "c" is probably not assigned 12345678, it is given a memory address.
Actually the string 12345678 is assigned to "c", because "c" is an array. If "c" was a char pointer, you'd be correct.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by derek7
Quote:
Original post by Boder
The compiler creates a place in memory with "123456789\0" not "1234567890" and points c to it.

But I can say that "c" is probably not assigned 12345678, it is given a memory address.


all char is number. so '\0\ is exact equal to 0. maybe I wrong.but it often confuse people. I thing \0 is exact a number it is 0.
Yes, \0 equals ASCII 0, but ASCII 0 does not equal '0'. That's got a code of 48 or something (Don't know the number off the top of my head)


if('\0' == 0)::MessageBox(0," equal ",0,0);

if('0' == 48)::MessageBox(0," equal ",0,0);

so \0 = number 0

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:
Original post by Boder
The compiler creates a place in memory with "123456789\0" not "1234567890" and points c to it.

But I can say that "c" is probably not assigned 12345678, it is given a memory address.
Actually the string 12345678 is assigned to "c", because "c" is an array. If "c" was a char pointer, you'd be correct.

Actually, an array is a pointer. I was lied to as a child.

Quote:
Original post by derek7
if('\0' == 0)::MessageBox(0," equal ",0,0);

if('0' == 48)::MessageBox(0," equal ",0,0);

so \0 = number 0

Uhh, you've just shown that the ASCII code for -

'\0' == 0
'0' == 48

Therefore '\0' != '0'.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mushu
Quote:
Original post by Anonymous Poster
Quote:
Original post by Boder
The compiler creates a place in memory with "123456789\0" not "1234567890" and points c to it.

But I can say that "c" is probably not assigned 12345678, it is given a memory address.
Actually the string 12345678 is assigned to "c", because "c" is an array. If "c" was a char pointer, you'd be correct.

Actually, an array is a pointer.

No.

John B

Share this post


Link to post
Share on other sites
I can only conclude that deep down, all arrays have an unquenchable desire to be pointers, as they will convert themselves to pointers at the slightest provocation. It's kind of sad, really. Hopefully one day they'll be more comfortable with themselves and not try to be what they assume everyone wants them to be. They will not find happiness by pretending to be something they're not.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!