Interview Question

What is a string in C?

A C string is a char sequence ending with a null character.

💡 Concept ✅ Quick Revision ⚙ C

Answer

A C string is a contiguous sequence of characters terminated by the null character. • A string occupies an array of char. • The terminator is written as `\0` and is part of the stored array. • String functions require a terminator within the accessible array bounds.

💡 C Example

char message[] = "Hello"; printf("%zu\n", strlen(message));

Output

5

⚡ Quick Revision

A C string is a char sequence ending with a null character.