Non-zero-terimated string

This is a discussion on Non-zero-terimated string within the C++ Programming forums, part of the General Programming Boards category; you constantly call nul-character "NULL". It is wrong. NULL is pointer and as so cannot be assigned to char or ...

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,589
    you constantly call nul-character "NULL". It is wrong. NULL is pointer and as so cannot be assigned to char or any other integer type...
    NULL is zero though, so it can be assigned to char or any integer type, just that it would not be semantically correct.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by laserlight View Post
    NULL is zero though, so it can be assigned to char or any integer type, just that it would not be semantically correct.
    ok, it should not be assigned... and after assignement is it already not NULL pointer, but 0
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,589
    and after assignement is it already not NULL pointer, but 0
    Yes, but to begin with NULL is 0 (or 0L, but not (void*)0). After all, unlike the proposed nullptr, it is not a null pointer, but a null pointer constant.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #19
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by vart View Post
    you constantly call nul-character "NULL". It is wrong. NULL is pointer and as so cannot be assigned to char or any other integer type...
    You're probably technically correct, but I just think of NULL == 0 == '\0'...
    Maybe they should have gave '\0' a more unique sounding name?

  5. #20
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by cpjust View Post
    You're probably technically correct, but I just think of NULL == 0 == '\0'...
    Maybe they should have gave '\0' a more unique sounding name?
    It doesn't sound different when pronounced, but in writing I refer to '\0' as "null" (lowercase) as opposed to NULL, which is a pointer. Yech.

  6. #21
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by cpjust View Post
    You're probably technically correct, but I just think of NULL == 0 == '\0'...
    Maybe they should have gave '\0' a more unique sounding name?
    ASCII calls it 'nul' or 'NUL' (not case-sensitive in the ASCII world).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #22
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,537
    MSDN calls it NULL char and it sounds better than NUL to me.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #23
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,589
    The C++ Standard itself calls '\0' the null character. I daresay it would be better not to call it the NULL character so as to avoid confusion, even though '\0' == NULL is true.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #24
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,537
    Well, null sounds better than nul, so that's fine.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #25
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well if its worth anything one would pronounce NUL and NULL the same, and the only reason it is NUL is because the names for ASCII chars are abbreviated. Thus NUL is just short for NULL anyhow. Careful when trusting MSDN. If I had a penny for every time I saw Microsoft Specific in bold at the top and bottom of a page, I'd be at the dollar menu as we speak!

  11. #26
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,537
    Yeah, but I didn't figure NULL char to be wrong. And no one objected when I mentioned MSDN used the phrase NULL char.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #27
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I have no problem with saying NULL char. Since it too is pronounced the same as '\0' I am not a big fan of either to be honest, however. 0 takes oh so much less time to type and is unmistakable (well at least as long as the letter "O" is not a variable )

  13. #28
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by Elysia View Post
    Yeah, but I didn't figure NULL char to be wrong. And no one objected when I mentioned MSDN used the phrase NULL char.
    I don't really see where it is... http://www.google.co.il/search?hl=en...soft.com&meta=
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  14. #29
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,537
    Unfortunately, I don't know where I found that. It may be lost with time. But I did find it mentioned "null char" in context on a page, too.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #30
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,589
    0 takes oh so much less time to type and is unmistakable (well at least as long as the letter "O" is not a variable )
    Use a better font?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compare structures
    By lazyme in forum C++ Programming
    Replies: 15
    Last Post: 05-28-2009, 02:40 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21