? (Question Mark) is ASCII code point 63 (0x3F), Unicode U+003F, and a printable punctuation character. It turns a statement into a question — a single glyph that reverses the entire force of a sentence, transforming a declaration into a request for information. Programming has found remarkably varied uses for this character. The ternary operator condition ? a : b appears across C, Java, JavaScript, and dozens of other languages, offering a compact if-else in expression form. In URLs, ? marks the boundary between the path and the query string (/search?q=hello), a separator so fundamental to the web that every form submission depends on it. SQL uses ? as a placeholder in parameterized queries, and regular expressions make it the "zero or one" quantifier — colou?r matches both "color" and "colour." More recently, Swift, Kotlin, TypeScript, and C# use ? for optional chaining and nullability: user?.address?.city short-circuits to null if any link in the chain is missing. The gotcha lives in regex greediness: appending ? after a quantifier like * or + switches it from greedy to lazy matching, so .*? and .* can return dramatically different results on identical input, and choosing the wrong one produces matches that are either too short or too long with no error to signal the mistake. The mark may descend from the Latin word "quaestio" (question), which medieval scribes abbreviated as "qo" stacked vertically — the q gradually stylized into the curve and the o shrinking to the dot below. UTF-8 encodes it as a single byte 0x3F. Unicode classifies it as Po (Punctuation, Other) with the name QUESTION MARK. The inverted question mark ¿ (U+00BF), required at the start of Spanish interrogative sentences, is its most familiar relative — a mirrored twin that English speakers almost never encounter outside language class.
const char *url = "/search?q=ascii"; // '?' starts the query stringconst char *qs = strchr(url, '?'); // Find delimiterconst char *param = qs ? qs + 1 : ""; // Skip '?' if present
The ? separates the path from the query string: /search?q=hello&lang=en. Everything after ? consists of key=value pairs joined by &. The server receives these as request parameters. Technically, ? is the only character that signals 'query string starts here' in the URL spec.
?. safely accesses nested properties without throwing if an intermediate value is null/undefined: user?.address?.city returns undefined instead of crashing. Before optional chaining, you needed verbose checks: user && user.address && user.address.city. It was added in ES2020.
? makes the preceding element optional (matches zero or one time). colou?r matches both 'color' and 'colour'. After a quantifier, ? makes it lazy (non-greedy): .*? matches as little as possible. In groups, ? enables special syntax: (?:...) for non-capturing, (?=...) for lookahead.
condition ? valueIfTrue : valueIfFalse is the conditional (ternary) operator — a compact if/else expression. Example: const label = age >= 18 ? 'adult' : 'minor'. It exists in C, JavaScript, Java, PHP, and most C-family languages. Nesting ternaries hurts readability — use if/else instead.