What does this mean???

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
// Ex4_07.cpp
// Initializing pointers with strings
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
char* pstr[] = { "Robert Redford", // Initializing a pointer array
"Hopalong Cassidy",
"Lassie",
"Slim Pickens",
"Boris Karloff",
"Oliver Hardy"
};
char* pstart("Your lucky star is ");
int dice(0);
cout << endl
<< "Pick a lucky star!"
<< "Enter a number between 1 and 6: ";
cin >> dice;
cout << endl;
if(dice >= 1 && dice <= 6) // Check input validity
cout << pstart << pstr[dice - 1]; // Output star name
else
cout << "Sorry, you haven't got a lucky star."; // Invalid input
cout << endl;
return 0;
}



How do I swap the pointers as described in this paragraph?

Space saving isn’t the only advantage that you get by using pointers. In a lot of circumstances you save
time, too. Think of what happens if you want to move "Oliver Hardy" to the fi rst position and "Robert
Redford" to the end. With the pointer array as in Ex4_07.cpp, you just need to swap the pointers — the
strings themselves stay where they are.

Can someone help me please?
1
2
3
char* temp = pstr[0];
pstr[0] = pstr[5];
pstr[5] = temp;
Topic archived. No new replies allowed.