Solved

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

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 writing to files in the C programming language.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now