By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

How to Produce OR (|) Character From the Keyboard

P: n/a
How to type an OR (|) character using the keyboard?
Nov 18 '10 #1
Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,494
This is not a C question really, but you either find the key on your keyboard (It won't be the same as mine so I can't help with that) or you hold the Alt key down and type its numerical code (124 decimal) on the numeric keypad. When you let the Alt key up it will show |.
Nov 18 '10 #2

Expert 100+
P: 2,400
There are three ways to enter the 'or' operator (|) into a C program:
  1. Type the | character on your keyboard (on mine it is shift-backslash; Neopa suggests a tricky way to type it).
  2. Use the three-character trigraph sequence ??! instead of the single character |.
  3. Include header file <iso646.h> and use macro bitor (for "|"), macro or (for "||"), or macro or_eq (for "|=").
Notice that options 2 and 3 provide the function of the 'or' operator; you will not see that character when you print your source code.

Trigraphs and <iso646.h> were provided by the committee specifically to allow C to be used in countries where computer keyboards frequently lack certain necessary C characters.

FYI, C99 adds digraphs, which provide yet another way to enter certain characters. However, there is no digraph for the 'or' operator.
Nov 18 '10 #3

NeoPa
Expert Mod 15k+
P: 31,494
Surely that makes 4 now Don?
Nov 18 '10 #4

Expert 100+
P: 2,400
I started counting from zero.
(Nobody expects the Spanish Inquisition.)
Nov 18 '10 #5

NeoPa
Expert Mod 15k+
P: 31,494
Thoroughly trumped :-<

Perfect answer :-D
Nov 18 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.