// replace string chars with repeated char // #include int replace( char *p, char c) { int len = 0; while( p[len] != 0) { p[len] = c; ++len; } return len; } int main( void) { char c = 'Z', str[] = "abcdefg"; printf( "c = %c\n", c); printf( "before replace: str = %s\n", str); int count = replace( str, c); printf( " after replace: str = %s\n", str); printf( "count = %i\n", count); } /* output: c = Z before replace: str = abcdefg after replace: str = ZZZZZZZ count = 7 */