Data for C Programmings
Data handling in C covers arrays, strings and input and output. Arrays are contiguous blocks of one type, and strings are char arrays ending in a null byte, with no built-in length or bounds checking. The standard library offers printf, scanf, fgets and string functions to read and process them.
Stage: Language Basics · Part of the C Programming roadmap · Last reviewed 19 November 2026
What to learn in Data
- Declare, initialise and iterate over a one and two dimensional array
- Explain the null terminator and compute a string's length manually
- Use fgets instead of gets and strip the trailing newline
- Copy and compare strings safely with strncpy-style bounds and strcmp
- Spot a buffer overflow caused by writing past the end of an array
Data interview questions
Why is gets unsafe and what replaces it?
gets reads input without any limit on length, so long input overwrites memory beyond the buffer, causing crashes or security holes. It was removed from the C11 standard. Use fgets with the buffer size instead.
What is the difference between char s[] and char *s for a string literal?
char s[] = "hi" creates a modifiable array copy on the stack. char *s = "hi" points to a string literal stored in read-only memory, and modifying it is undefined behaviour. Use const char * for literals.
Where Data fits in the C Programming roadmap
Data belongs to the Language Basics stage (beginner level), which takes about 30 hours. Syntax and types.
Other units in this stage
Back to the full C Programming roadmap