Solved

what is the use of " | " in c language?

Posted on 2011-02-24
3
351 Views
Last Modified: 2012-05-11
char x;
char y;
char z;
z= x | y;
I was wondering what is the use of " | " in c language, does it add bits?

0
Comment
Question by:logicallayer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 34969238
the result is the bitwise inclusive OR function of its operands.
0
 
LVL 34

Assisted Solution

by:sarabande
sarabande earned 125 total points
ID: 34969331
the bitwise or means that any bit set in either operand x or y would be set (1) in z.

contrary logical & is bitwise and and z would have only those bits set which were both set in x and y.

Sara
0
 

Author Closing Comment

by:logicallayer
ID: 34969473
now it make sense, as I was going through a code of friend and this totally explains it...

thanks for both of you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question