Hello,
I am only starting to design a C program that opens a file;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
FILE *fp;
fp = fopen ("file.txt", "r");
if (fp == NULL)
{
perror("Can't open the file");
return EXIT_FAILURE;
}
printf ("%d\n", fp);
system("pause");
return EXIT_SUCCESS;
}
The file is a text says "the quick brown fox jumps over the lazy dog", but when I ran the program, it showed some random number than I expected :confused: How do you run the program to open the file within the terminal?
My goal is to replace a character, and the option must be supplied via command line arguments.
For example, the original text file shows
"the quick brown fox jumps over the lazy dog"
and if the program runs, using the following command line:
"assignment1 abc DEF input"
to replace from a to D, b > E, c > F
then the file should have the following contents:
"the quiFk Erown fox jumps over the lDzy dog"
It would be great if you give me an example of codes for those functions.