Displays a string with pointer notation - C++ Data Type

C++ examples for Data Type:char array

Description

Displays a string with pointer notation

Demo Code

#include <iostream>
using namespace std;
int main()//from   w w  w .  j  a  va  2 s . co 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;
}

Result


Related Tutorials