/*
beany.str: Reality isn't what is used to be.
beany.ct:33
beany.str: Reality isn't what is used to be.
beany.ct:33
beany.str: Reality isn't what is used to be.
beany.ct:33
Duality isn't what is used to be.
Duality isn't what is used to be.
Duality isn't what is used to be.
Duality isn't what is used to be.
*/#include <iostream>#include <cstring>usingnamespacestd;
struct stringy {
char * str; // points to a stringint ct; // length of string (not counting '\0')
};
voidset(stringy & b, char test[], int i = 0);
void show(stringy & b, int i = 1);
void show(char test[], int i = 1);
//prototypes for set(), show(), and show() go hereint main() {
stringy beany;
char testing[] = "Reality isn't what is used to be.";
set(beany, testing);
show(beany);
show(beany, 2);
testing[0] = 'D';
testing[1] = 'u';
show(testing);
show(testing, 3);
//show("Done!");return0;
}
voidset(stringy & b, char test[], int i) {
int n = (int)strlen(test);
b.ct = n;
b.str = newchar [n];
strcpy(b.str, test);
}
void show(stringy & b, int i) {
while (i--) {
cout << "beany.str: " << b.str << "\n";
cout << "beany.ct:" << b.ct << "\n";
}
}
void show(char test[], int i) {
while (i--)
cout << test << "\n";
}