#include <iostream>
using std::cout;
using std::endl;
using std::cin;
#include <cstdlib>
#define PAGES 2
#define ROWS 4
#define COLS 20
//function is used to populate char *** array
//first param is 3 d pointer to character array
//2nd parameter's analogy is same a page of note book
//3rd paramter's analogy is same as rows in a page of note book
void fillArray ( char ***, const int, const int );
//function is used to display char *** array
//first param is 3 d pointer to character array
//2nd parameter's analogy is same a page of note book
//3rd paramter's analogy is same as rows in a page of note book
void displayArray ( char ***, const int, const int );
int main ()
{
system ( "color 3e" );
system ( "title Shafiq Hussain" );
// ptr is a pointer to a pointer to a pointer to char
char ***ptr;
// Memory allocating
//ptr points to PAGES time pointer to pointer to char
ptr = new char ** [PAGES];
for ( int page = 0; page < PAGES; page ++ )
{
//Each pointer to pointer to char has ROWS times an array to char
ptr [page] = new char * [ROWS];
for ( int row = 0; row < ROWS; row ++ )
{
// each pointer to pointer to pointer points COLS times
// characters in the memory
ptr [page][row] = new char [COLS];
}
}
// Now taking input from user
// Two pages
// Each page has 4 lines
// Each line has 20 characters
// I have to save all names in 2 pages//4 rows//20 chars
fillArray ( ptr, PAGES, ROWS );
// Displaying the pointer strings
displayArray ( ptr, PAGES, ROWS );
cout << endl << endl << endl;
system ( "pause" );
return 0;
}
void fillArray ( char ***ptr, const int pages, const int rows )
{
for ( int page = 0; page < pages; page ++ )
{
cout << "\t\t\t\tData in for page#" << page + 1 << endl << endl;
for ( int row = 0; row < rows; row ++ )
{
cout << "Please enter name for row#" << row + 1 << " : ";
cin >> ptr [page][row];
}
cout << endl << endl;
}
}
void displayArray ( char ***ptr, const int pages, const int rows )
{
for ( int page = 0; page < pages; page ++ )
{
cout << "\t\t\t\tData out for page#" << page + 1 << endl << endl;
for ( int row = 0; row < rows; row ++ )
{
cout << "In row#" << row + 1 << " name is: " << ptr [page][row] << endl;
}
cout << endl << endl;
}
}
0 Comments On This Entry
Trackbacks for this entry [ Trackback URL ]
← January 2022 →
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
Tags
My Blog Links
Recent Entries
-
pointer to pointer to pointer to character stringon Apr 22 2011 08:07 PM
Search My Blog
1 user(s) viewing
1 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)



Leave Comment








|