What type is used to define strings in the C language?
In C language, there are two different ways to define strings.
- By using a character array, you can store a sequence of characters to represent a string. For example:
char str[] = "Hello World";
- Using character pointers: By defining a pointer to a character array, you can store the address of a string to represent the string. For example:
char *str = "Hello World";
Both methods can be used to define and operate with strings, but it is important to note that strings defined using character pointers are constants and cannot be changed by modifying the string. On the other hand, strings defined using character arrays are mutable and can be changed by modifying the array elements.