#include size_t replace(char* text, char find, char replace) { size_t count = 0; for ( ; *text; ++text ) if ( *text == find ) { *text = replace; ++count; } return count; } int main(int argc, char* argv[]) { if ( argc <= 3 ) return fprintf(stderr, "Usage: replace a b texts\n"); char find = *argv[1], repl = *argv[2]; size_t count = 0; for ( int i = 3; i < argc; ++i ) { count += replace(argv[i], find, repl); printf("%s ", argv[i]); } printf("\n%zi replaces\n", count); return 0; }