Hello help please
there is a text file, I want to remove from it all sentences ending with an exclamation mark.
I only did what removes the mark itself, how do I remove the whole sentence?
there is a text file, I want to remove from it all sentences ending with an exclamation mark.
I only did what removes the mark itself, how do I remove the whole sentence?
C:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int c = 0;
const unsigned char discard = '!';
const char *file_name = "ex1.txt";
FILE *input_file = NULL, *output_file = NULL;
if (!(input_file = fopen(file_name,"r")) || !(output_file = fopen("ex2.txt","w")))
{
fprintf(stderr,"error handling");
exit(EXIT_FAILURE);
}
while ((c = fgetc(input_file)) != EOF)
{
if (c != discard)
{
fputc(c,output_file);
}
}
fclose(input_file);
exit(EXIT_SUCCESS);
}