C++ char array Display an array of characters via pointer and array index
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main(int nNumberofArgs, char* pszArgs[]) { const char* szString = "test test"; cout << "The array is '" << szString << "'" << endl; cout << "Display the string as an array: "; for(int i = 0; i < 5; i++){ cout << szString[i];//from ww w . ja v a 2 s .c o m } cout << endl; cout << "Display string using a pointer: "; const char* pszString = szString; while(*pszString){ cout << *pszString; pszString++; } cout << endl; return 0; }