some C operands...

This is a discussion on some C operands... within the C Programming forums, part of the General Programming Boards category; Hi... i have a simple question: what does this mean | ? and what does this mean & ? please ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    18

    some C operands...

    Hi...
    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.
    thanx.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Bitwise or and bitwise and operate on bits.
    http://web.archive.org/web/200502070...ft.html#3.3.10
    Code:
    #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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    18
    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, 10: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, 11:08 AM
  5. Need help with C program
    By ChrisH in forum C Programming
    Replies: 38
    Last Post: 11-13-2004, 12:11 AM

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