char c[] = "12345678"

Started by
20 comments, last by MaulingMonkey 17 years, 11 months ago
you see, c is actually assigned to 123456780. when the 0 is plugin?
Advertisement
Underneath.
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.
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.
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)
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.

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
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'.
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
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
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.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.

This topic is closed to new replies.

Advertisement