We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,599 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Literal single quote char

Hi, I'm hoping someone might be able to help me with what I think might be a simple problem.
I have came across the need to add to an unsigned char array a literal single quote "'"

My question is how can I achieve that?

unsigned char uArray[4];
uArray[0] = 'I';
uArray[1] = 't';
uArray[2] = '''; // here is where my problem lies
uArray[3] = 's';

The quote I need to insert, is closing the opening quote.

I appreciate any help offered.

(edit)

Sorry if you wasted time reading this, I found solution.
I guess sometimes I need to write a question down before the answewr comes to me.

uArray[2] = 39;

Thank you.
Solved.

2
Contributors
3
Replies
54 Minutes
Discussion Span
9 Months Ago
Last Updated
4
Views
Question
Answered
Suzie999
Posting Whiz
322 posts since Jul 2010
Reputation Points: 49
Solved Threads: 15
Skill Endorsements: 0
Question Self-Answered as of 9 Months Ago

It's good that you found something that worked. However, you may be interested in finding out more about escape sequences, which allow you to use:

uArray[2] = '\''; // single quote + backslash + single quote + single quote

There are others, besides this one for the single quotation mark, such as:

\" for double quotation mark
\? for question mark
and a double backslash to represent the backslash

One of the most common that people come across is \n for newline, perhaps not realising that it belongs to a group of such escape sequences. A quick search on Google with give you a list of them.

Bob
using namespace Bob
Team Colleague
221 posts since Feb 2003
Reputation Points: 30
Solved Threads: 11
Skill Endorsements: 0

Of course, I'm such a dimwit at times :(

I even used the escape to add a terminator '\0'.

Duh!

Thanks for the heads up.

Suzie999
Posting Whiz
322 posts since Jul 2010
Reputation Points: 49
Solved Threads: 15
Skill Endorsements: 0

Of course, I'm such a dimwit at times :(

Who isn't? No worries.

Bob
using namespace Bob
Team Colleague
221 posts since Feb 2003
Reputation Points: 30
Solved Threads: 11
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0632 seconds using 2.68MB