Strings as arguments
// displays a string with pointer notation
void main()
{
void dispstr(char*); // prototype
char str[] = ”Strings and pointers ";
dispstr(str); // display the string
}
void dispstr(char* ps)
{ cout << endl;
while( *ps ) // until null character,
cout << *ps++; // print characters
}
Previous slide
Next slide
Back to first slide
View graphic version