title: How do I write a program to swap a character in the input file with a character specified on the command line?
body: <p>I'm trying to write a program to swap a character that I would specify on the command line (a command line argument) with a character in the input text file. The first command line argument is the character I want to change, the second argument is character that I want to replace the old character with, and the third argument is the input file. </p>
  
  <p>When I do this, my program should generate an output file named: "translation.txt". I know that the problem with my program is in the "if" statements/the fprintf statements, but I'm not sure how to fix this. I was thinking of reading each character in the input file separately, and from there, I wanted to use "if" statements to determine whether or not to replace the character. </p>
  
  <pre><code>void replace_character(int arg_list, char *arguments[])
  {
     FILE *input, *output;
  
     input = fopen(arguments[3], "r");
     output = fopen("translation.txt", "w");
  
     if (input == NULL)
     {
        perror("Error: file cannot be opened\n");
     }
  
     for (int i = 0; i != EOF; i++)
     {
        if (input[i] == arguments[1])
        {
           fprintf(output, "%c\n", arguments[2]);
        }
        else
        {
           fprintf(output, "%c\n", arguments[1]);
        }
     }
  }
  
  int main(int argc, char *argv[])
  {
     if (argc &lt; 5)
     {
        perror("Error!\n");
     }
  
     replace_character(argc, argv);
  }
  </code></pre>