Solved

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

Posted on 2011-02-24
3
350 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

713 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