Hey,
I need to write a program that opens a text file, removes characters such as "@, £" etc which are placed in the middle of words, when an "i" occurs on its own, change it to a capital "I", change the first letter of each sentence to a capital (after every full stop has to be a capital), and then finally write the edited file to a new file
I'm able to write code that opens the existing file and writes it to a new one, however i dont know where to start on writing code to edit the text, i believe that if statements and loops are needed (?)
I'm a total beginner as i'd never programmed before i started my degree, and i'm really stuck.
Any help you could give me would be much appreciated
Here is what i have so far:
Code:
#include <stdio.h>
int main(void)
{
FILE *swbtxt; // declare file pointer
FILE *destination;
char buffer [10000];
int num;
swbtxt = fopen ("swbtxt.txt","r"); // opens the file
destination = fopen("dest.txt", "w");
if ((swbtxt !=NULL) && (destination !=NULL))
{
num = fread(buffer,1,10000,swbtxt); // read text
fwrite(buffer,1,num,destination); // write text
fclose(swbtxt); // close file
fclose(destination); // close file
printf ("Finished: swbtxt.txt copied to dest.txt");
printf ("\n%d characters copied\n", num);
return 0;
}
else
{
if (swbtxt == NULL)
printf("Unable to Open swbtxt.txt\n");
if (destination == NULL)
printf ("Unable to Open dest.txt\n");
return 1;
}
}
Im attatched the exisiting file I have to work from