#include <iostream> #include <cstring> using namespace std; void center(char *s); int main() { center("www.java2java.com!"); center("www.java2java.com"); return 0; } void center(char *s) { int len; len = 40+(strlen(s)/2); cout.width(len); cout << s << '\n'; }