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! While you're at it, check out some resources Treehouse students have shared here.
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 trialNicole Freed
695 PointsDifference 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
47,913 PointsSingle 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";
Tristan Gaebler
6,204 PointsI 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.
Nicole Freed
695 PointsNicole Freed
695 PointsOhโ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
47,913 PointsMichael Hulet
47,913 PointsRemember that the C compiler was written in 1972 (a full 12 years before the first Mac was announced)
Nicole Freed
695 PointsNicole Freed
695 PointsDidn't know that!