Mega Code Archive

 
Categories / C++ / Function
 

Pass string (char ) into a function

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