- A string
variable is
just an array of
char in
C
Example:
char line[11]; // Can store a string of 10 chars
// The sentinel '\0' takes up 1 char
|
- Example
using a
string variable:
int main(int argc, char *argv[])
{
char a[10] = { 'H', 'e', 'l', 'l', 'o', '\0' } ;
// Don't forget the sentinel '\0'
// used to end the string !
printf("String a = %s\n", a ); // Print string
printf("Quiz: %s\n", &a[1] ); // Print ???
}
|
|