In C, a string is a sequence of characters stored in an array.
Strings must end with a special character called the null terminator (\\0).
You can initialize strings using double quotes.
The compiler automatically adds the null terminator.
Use printf with %s to print strings.
Strings can be accessed like arrays using indexes.
Indexing starts at 0.
You can loop through a string until you reach the null terminator.
The string.h library provides useful functions for working with strings.
Some important string functions include:
strlen() – get lengthstrcpy() – copy stringstrcat() – concatenate stringsstrcmp() – compare stringsYou can modify characters in a string if it is stored in an array.
Strings can also be represented using pointers.
However, modifying them may not always be allowed.
Be careful with these:
Strings are used in almost every program for handling text.
Create a string and print each character using a loop.