Strings in C are arrays of characters terminated by a null character ‘\0’.
- You can use pointers to access and manipulate strings.
- Pointer arithmetic helps traverse strings character by character.
- A string literal can be assigned to a char * pointer.
- Dereferencing and pointer arithmetic allow access to each character.
Example:
#include <stdio.h>
int main() {
char str[] = "Hello";
char *ptr = str;
while (*ptr != '\0') {
printf("%c ", *ptr);
ptr++;
}
printf("\n");
return 0;
}