1: // Filename: CSTRPTR.CPP 2: // Purpose: Illustrates the connection between pointers and C-strings. 4: #include <iostream> 5: using namespace std; 7: int main() 8: { 9: cout << "\nThis program illustrates pointers with C-strings." 10: << "\nStudy the source code and the output simultaneously.\n\n"; 12: char str[] = "Springtime"; 15: char* cPtr = str; 16: while (*cPtr != '\0') 17: { 18: cout << *cPtr; // Output the ***character*** pointed to 19: cPtr++; 20: } 21: cout << endl << endl; 24: cPtr = str; 25: while (*cPtr != '\0') 26: { 27: cout << cPtr << endl; // Output the ***string*** pointed to 28: cPtr++; 29: } 30: cout << endl << endl; 32: return 0; 33: }