Programming Fundamentals · Interview question

Why is 'A' different from "A"?

A strong answer

'A' is a single char, one byte holding the value 65 (the ASCII code for capital A). "A" is a string literal, an array of two chars: 'A' followed by a null terminator '\0' marking the end. The compiler treats them with completely different rules: char c = 'A' works, but char c = "A" is a type error because you're trying to fit a pointer-to-array into a single byte. Single quotes for a character, double quotes for text.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

Variables & Data Types

Named boxes that hold a value. Pick a type, declare, assign, and learn why C makes you say what kind of thing each box holds.

More Variables & Data Types questions

Browse all 472 interview questions