/*
 * Description: Substitute a byte in input bytes
 * Usage: subst a b
 * Parameter a: the byte to substitute
 * Parameter b: the substitution byte
 * Copyright: Daniel Tisza, 2010
 * All rights reserved
 */

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
  int c;
  int a;
  int b;

  if (argc != 3) /* validate argument count */
  {
    return 0;
  }

  a = (int)*argv[1];
  b = (int)*argv[2];
  
  while ( (c = getchar()) != EOF) /* for all input characters */
  {
    if (c == a)
    {
      c = b;
    }
    printf("%c", c);
  }
}

