C++, C String, Character Array and character pointer

Опубликовано: 12 Октябрь 2024
на канале: RioProfessor Liu
47
0

C-String can be represented in 3 different ways

1. C-String as string literal : string name= "CIT 126 Professor";
cout name ; // display "CIT 126 Professor"

2. C-String as array of character: char professorName[] = "Professor Liu";
cout professorName ; // display "Professor Liu"

3. uses a pointer to char to point to a C-String whose storage has already been allocated by the first or second method:

char* p;
p = professorName;
cout p ; // display "Professor Liu"