C syntax

This is a discussion on C syntax within the C Programming forums, part of the General Programming Boards category; Does anyone know how many different ways you can write a statement to add 1 to a variable? i.e., x=x+1; ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    1

    Exclamation C syntax

    Does anyone know how many different ways you can write a statement to add 1 to a variable?
    i.e., x=x+1;
    x++;

    Thanks

  2. #2
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    x=x+1; or
    x++; or
    ++x;, i think that's all.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    don't forget x+=1;

    That's my personal favorite because you can increase x by any number, not just 1.

    --starx
    www.axisoftime.com

  4. #4
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    He he, I totally forgot about that one.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    I think this will work, at least for signed values.
    x = -~x;
    Callou collei we'll code the way
    Of prime numbers and pings!

  6. #6
    Unregistered
    Guest
    i|=1 ... sometimes...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 09:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

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