What's with "\" ???

Started by
16 comments, last by Gaiiden 23 years, 5 months ago
And both forward and double back slashes can be used to delineate path names.


Please state the nature of the debugging emergency.


sharewaregames.20m.com

Advertisement
quote:Original post by furby100

And both forward and double back slashes can be used to delineate path names...



... in DOS based systems.

I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
just remember that \ is the escape character. When found in a string:

\\ = \
\" = "
\n = newline
\r = carriage return
\t = tab
\0 = NULL
quote:Original post by JonStelly

Guys, I'm no unix expert, but how often do you see the string "c:\" in unix? =)


Hahahahaha!

Excuse me whilst I conquer Earth...

Commander M
(a.k.a. Crazy Yank)
http://commanderm.8m.com
CmndrM@gdnmail.net

Edited by - CmndrM on October 30, 2000 4:47:11 PM
quote:Original post by JonStelly
\0 = NULL


Technically, \0 is not always the same as NULL. NULL is the value of a pointer which does not point to any memory. \0 is the value of a character which is not defined. They do not have to be the same, although they are on DOS based Intel compatible platforms.


Please state the nature of the debugging emergency.


sharewaregames.20m.com

True enough, I just don''t know of any systems where (''\0'' != NULL), can anyone point one out, I''m interested now.
quote:Original post by furby100

Original post by JonStelly
\0 = NULL


Technically, \0 is not always the same as NULL. NULL is the value of a pointer which does not point to any memory. \0 is the value of a character which is not defined. They do not have to be the same, although they are on DOS based Intel compatible platforms.



"\0" is not the value of a character which is undefined. "\0" represents the "null character", which has the ASCII code ''0'' (zero). The reason NULL==''\0'' is this: ''\0'' represents a byte (unsigned char) with value 0. NULL represents a pointer (stored as a long) with no value, which is also stored as 0. Hence, 0==0…

"Technically", they''re not the same because one represents a long and one represents an unsigned char, but they have the same value.

Of course, ''0'' has a value of 48 (0x30), it''s ASCII code.
Time to clear some confusion about NULL! According to the ISO C++ standard, NULL is defined as integer 0, but may not be represented in memory as 0. Therefore...

void* a = 0; // a does not point to anything
void* b = NULL; // a == b
void* c = 1; // error (can only convert integer 0 to ptr!)

However... Assigning zero to a pointer merely says you want a pointer that points to nothing. That doesn''t mean that the pointer is represented in memory by a 0. Therefore, the following two statements are not equivalent. (assuming ptr is a void*)

ptr = 0;
memset(&ptr, 0, sizeof(ptr));

Granted, I do not know of a platform where NULL pointers are not represented as 0 (actually, I think NeoTuri in DALnet #programmers said some RISC platform used -1 (0xFFFFFFFF), but I can''t verify that). According to the C++ standard though, it can happen.

AegisKnight
http://www.nerv-un.net/~aegis/

This topic is closed to new replies.

Advertisement