Specifying a "null" character

This is a discussion on Specifying a "null" character within the C Programming forums, part of the General Programming Boards category; Is there any way to specify a "null" character? Code: char test; test=""; and test='' doesn't work. Returns an error ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    98

    Specifying a "null" character

    Is there any way to specify a "null" character?
    Code:
    char test;
    test=""; and test='' doesn't work. Returns  an error message.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    230
    well a null character equals to '\0'. so you can try
    Code:
    test = '\0'
    someone could correct me if i'm wrong.

  3. #3
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    269
    or

    char test=0;

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >or
    >char test=0;
    It's best to use the literal that best reflects the type you're working with. For pointers that means NULL, for characters that means '\0'. 0 will work for both, but it has a tendency to hurt the self-documentation of your code.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 10-07-2008, 06:19 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. syntax error when defining vectors
    By starkhorn in forum C++ Programming
    Replies: 5
    Last Post: 09-22-2004, 12:46 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM

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