Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Functional Programming in C While & Do While Loop

Difference between single (') and double (") quotes?

What's the difference in usage between single (') and double (") quotes in Objective-C? I'm seeing that there clearly is one, because I tried to write code that required single quotes with double ones, and it didn't execute properly. However, I'm not seeing what that difference is. Can anyone explain?

Thanks, Nicole

2 Answers

Michael Hulet
Michael Hulet
47,909 Points

Single quotes denote a single character in the C programming language, but double quotes denote a string of characters. In other words:

//Single quotes can only hold a single character...
char character = 'a';

//...but double quotes can hold any amount of characters
char string[] = "A string of characters";

Ohโ€”well, that's simple enough, although you'd think it would be easy for an interpreter to distinguish between a single character and a string without the quotes. I was thinking it was something much more arcane... :)

Michael Hulet
Michael Hulet
47,909 Points

Remember that the C compiler was written in 1972 (a full 12 years before the first Mac was announced)

Didn't know that!

I assume you are talking about a printf statement. If you use those interchangeably your going to get an error. It's going to get confused wether your talking about a single quote or an apostrophe . That's my guess. I'm new to C and Objective-c as well.