Thread: some C operands...

  1. #1
    Registered User
    Join Date
    Aug 2006

    some C operands...

    i have a simple question:
    what does this mean | ?
    and what does this mean & ?
    please note i'm not talking here about the operand "or"
    and i'm not talking about the operand "and"
    would you please give me a very simple example about that.
    i'm using the DJGPP compiler.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Bitwise or and bitwise and operate on bits.
    #include <stdio.h>
    int main(int argc, char *argv[])
       unsigned int x = 0x11;
       printf("x = 0x%x\n", x);
       printf("x & 0x1 = 0x%x\n", x & 0x1);
       printf("x | 0x2 = 0x%x\n", x | 0x2);
       return 0;
    /* my output
    x = 0x11
    x & 0x1 = 0x1
    x | 0x2 = 0x13
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Show some code in context - your question makes no sense.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Aug 2006
    thank you Dave_Sinkula

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. modulus operator with double operands?
    By chickenandfries in forum C Programming
    Replies: 7
    Last Post: 03-28-2008, 07:21 AM
  2. Quick question about invalid operands!
    By chocobo59 in forum C Programming
    Replies: 3
    Last Post: 12-03-2007, 11:50 AM
  3. Invalid Operands
    By chocobo59 in forum C Programming
    Replies: 6
    Last Post: 10-12-2007, 04:27 PM
  4. Replies: 17
    Last Post: 02-27-2006, 12:08 PM
  5. Need help with C program
    By ChrisH in forum C Programming
    Replies: 38
    Last Post: 11-13-2004, 01:11 AM