PDA

View Full Version : How do I type the character on mac keyboard?




brightside1863
Oct 7, 2010, 08:21 AM
I'm teaching myself C and can't find how to type the symbol into xcode. If I copy and paste from a WP program xcode throws up an error when building the code.
I'm assuming that this is due to it being copied and pasted, unless xcode recognises another character as the OR bitwise operator?

Can anyone help?



robvas
Oct 7, 2010, 08:24 AM
I'm teaching myself C and can't find how to type the symbol into xcode. If I copy and paste from a WP program xcode throws up an error when building the code.
I'm assuming that this is due to it being copied and pasted, unless xcode recognises another character as the OR bitwise operator?

Can anyone help?

Shift + the key above the return key?

Blue Velvet
Oct 7, 2010, 08:26 AM
You mean a pipe? Like so?

|

Shift + Back Slash \ (next to return key)

jared_kipe
Oct 7, 2010, 11:13 AM
... If I copy and paste from a WP program xcode throws up an error when building the code. ...

Is anyone e|se curious what a "WP program" is?

The on|y thing I can think of is Word Press.

lee1210
Oct 7, 2010, 11:22 AM
I guess maybe I'm actually old enough to thing "WordPerfect" instead of "WordPress"?

-Lee

gnasher729
Oct 7, 2010, 11:31 AM
I'm teaching myself C and can't find how to type the symbol into xcode. If I copy and paste from a WP program xcode throws up an error when building the code.
I'm assuming that this is due to it being copied and pasted, unless xcode recognises another character as the OR bitwise operator?

Can anyone help?

For the broken bar character use "Character Viewer". It won't compile unless you use it in a string literal or a comment. For the vertical line character | - what keyboard do you have? Many keyboards have it printed on the keyboard, for others check out the "Keyboard Viewer".

jared_kipe
Oct 7, 2010, 11:35 AM
I guess maybe I'm actually old enough to thing "WordPerfect" instead of "WordPress"?

-Lee

I actually did think of that, but I couldn't think of why someone would have a "program" in WordPerfect. You would think a C program from that era would be in .txt or some other plain text format/encoding.

I kinda assumed WordPress because it was more logical to myself that the OP was copying a program from someone's blog or tutorial.

Also I could see WordPress "stylizing" the text in some way by replacing | with

jared_kipe
Oct 7, 2010, 11:39 AM
For the broken bar character use "Character Viewer". It won't compile unless you use it in a string literal or a comment. For the vertical line character | - what keyboard do you have? Many keyboards have it printed on the keyboard, for others check out the "Keyboard Viewer".

You need to turn this feature on, its in...

System Preferences->Keyboard (Keyboard Tab)
AND
System Preferences->Language&Text (Input Sources tab)

EDIT: at least in 10.6, in earlier versions I believe it was only in Language&Text

FourCandles
Oct 7, 2010, 11:41 AM
I guess maybe I'm actually old enough to thing "WordPerfect" instead of "WordPress"?

-Lee

Meh, I was always a WordStar fan. Used it a lot (in plain text mode, or whatever it was called) for editing CBASIC files before compiling. :)

Sydde
Oct 7, 2010, 12:22 PM
Typically, when you see "a WP program" it stands for the generic "Word Processor". Kind of an archaic phrase that has been out of usage for at least half a dozen Moores.

brightside1863
Oct 10, 2010, 03:51 PM
You need to turn this feature on, its in...

System Preferences->Keyboard (Keyboard Tab)
AND
System Preferences->Language&Text (Input Sources tab)

EDIT: at least in 10.6, in earlier versions I believe it was only in Language&Text

Thanks. Having the character viewer on the menu bar will come in very handy. As for the broken bar, it keeps throwing up a 'stray 302' error when it's used in any code i'm writing.
Which from what I can find means that it's unrecognised?

angelwatt
Oct 10, 2010, 03:54 PM
Thanks. Having the character viewer on the menu bar will come in very handy. As for the broken bar, it keeps throwing up a 'stray 302' error when it's used in any code i'm writing.
Which from what I can find means that it's unrecognised?

Does that include when used in a string literal? As mentioned earlier (post 6) it can't be used in code except in string literals.

gnasher729
Oct 10, 2010, 04:27 PM
Thanks. Having the character viewer on the menu bar will come in very handy. As for the broken bar, it keeps throwing up a 'stray 302' error when it's used in any code i'm writing.
Which from what I can find means that it's unrecognised?

The "bitwise or" operator | and the "logical or" operator || are written using the vertical line, not the broken bar character. So yes, it won't compile, just like if you put any other random character in your code. For example, if (x ≠ y) won't compile either, nor will (a ≥ b) or (a ≤ b).


Does that include when used in a string literal? As mentioned earlier (post 6) it can't be used in code except in string literals.

Should work fine inside a string literal. What might come unexpected is that XCode will use UTF-8 for string literals, and the broken bar is not a single byte character. So strlen ("") will return 2, not 1 as you might expect.

brightside1863
Oct 11, 2010, 04:29 AM
The "bitwise or" operator | and the "logical or" operator || are written using the vertical line, not the broken bar character. So yes, it won't compile, just like if you put any other random character in your code. For example, if (x ≠ y) won't compile either, nor will (a ≥ b) or (a ≤ b).




Should work fine inside a string literal. What might come unexpected is that XCode will use UTF-8 for string literals, and the broken bar is not a single byte character. So strlen ("") will return 2, not 1 as you might expect.


Whizzer! Thanks gnasher729.