Thread: Emptying Values

  1. #1
    Registered User GreenCherry's Avatar
    Join Date
    Mar 2002
    Posts
    65

    Emptying Values

    how do you make an integer worth nothing? Would you use empty[x]? I haven't tried that yet. And I am assuming you empty an apstring by doing:
    x = "";
    Quick answers would be appreciated.

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Make it equal to 0?

    int i = 200;

    // ...

    i = 0;

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    This empties the interger t, with error checking to make sure it really is emptied.
    Only works on x86 compatible processors though.
    Code:
        int t;
        __asm
        {
         mov cx, 0x003f
         cpuflag:
           mov t,0
           cmp t,0
           je exception
         loop cpuflag
         exception:
        }
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    As long as a variable "exists" and as long as it is in scope, it has to have some value. It can contain zero, but I wouldn't call a numerical variable "empty". Variables "point to" physical memory (probably a bad choice of words because we're not talking about pointers.) That physical memory has some binary number in it... maybe zero!

    C++ finds the end of a string by looking for the first NULL (zero). So a string that starts with NULL (often expressed as '\0') will be treated as "empty" and will have a length of zero.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. putting values into an array
    By zdream8 in forum C Programming
    Replies: 15
    Last Post: 05-21-2008, 11:18 PM
  2. Replies: 1
    Last Post: 12-30-2007, 10:08 AM
  3. Need help with project
    By chrisa777 in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2006, 05:01 PM
  4. Replies: 1
    Last Post: 02-03-2005, 03:33 AM
  5. adding ASCII values
    By watshamacalit in forum C Programming
    Replies: 1
    Last Post: 12-26-2002, 07:16 PM