in reply to Re: what does goto ""; mean?
in thread what does goto ""; mean?

Just to add on top of what Abigail-II mentioned (why it is worth to mention "\x00"?).

If Perl, "" and "\x00" are not the same: (for people from c background, this is different in Perl and c.)

use strict; use warnings; if ("\x00" eq "") { print "they are the same"; } else { print "they are not the same"; }

But they are the same in c/c++:

#include <iostream.h> int main() { if (!strcmp("", "\x00")) { cout << "they are the same" << endl; } else { cout << "they are different" << endl; } }

Replies are listed 'Best First'.
Re^2: what does goto ""; mean?
by Aristotle (Chancellor) on Dec 11, 2003 at 17:23 UTC
    Careful. They're treated the same in C, but they're not. The difference between "" and "\x00" is that the former is one byte long, whose value is null, while the latter is two bytes long - two nulls. But since everything in C treats a null as end-of-string, the difference is not apparent anywhere.

    Makeshifts last the longest.

      This is the synergy of a cyber-team. We are together adding blocks to build our tower.

      Obviously I agree with you. The actually memory setting of “” and “\x00” are different, but the interpretation (when it is exposed to programmers as string) in c is the same. We can actually see two layers:

      • The actual data storage in memory
      • The interpretation offered by the language
        The interpretation offered by the language
        To be pedantic - that's not quite right either. The C language doesn't know anything about NUL terminated strings. It's the C library (and the str...() functions in particular) that use this convention.

        Michael (OK, I'll stop splitting hairs now :-)

      The difference between "" and "\x00" is that the former is one byte long, whose value is null, while the latter is two bytes long - two nulls.
      The character '\0' is the NUL (single L) character. NULL (double L) is a pointer, not a character.

      Abigail