/* testpointer4.cpp CIS 150 David Klick 6/28/05 Using pointers to work with strings. */ #include using std::cout; void upper1(char* str); char* upper2(char* str); int main(void) { char line1[] = "All the King's horses"; char line2[] = "and all the King's men"; cout << line1 << '\n'; cout << line2 << '\n'; // make the strings uppercase and display them upper1(line1); cout << line1 << '\n'; cout << upper2(line2) << '\n'; return 0; } void upper1(char* str) { upper2(str); } char* upper2(char* str) { char *p = str; while (*p != '\0') { if (*p >= 'a' && *p <= 'z') { *p = *p + ('A' - 'a'); } p++; } return str; }