C++ char array Displays a string with pointer notation

Description

C++ char array Displays a string with pointer notation

#include <iostream>
using namespace std;
int main()//from  w w  w . jav a  2 s.  c o m
{
   void dispstr(char*);     //prototype
   char str[] = "this is a test test.";
   dispstr(str);            //display the string
   return 0;
}
void dispstr(char* ps)
{
   while( *ps )             //until null character,
      cout << *ps++;        //print characters
   cout << endl;
}



PreviousNext

Related