In the text.txt file, I have some lines like "Apples are red.guavas are green.lemons are yellow". I want the the first letters in new lines(g in guavas,l in lemons to be capital).But the output in the file is the same...
#include<stdio.h>
main()
{
FILE *p;
char c;
int i;
int end_of_line=0;
p=fopen("text.txt","r+");//opening file for reading & writing.
while(c!=EOF)
{
c=fgetc(p);
if(end_of_line==1) // if it is a new line
if (islower(c)!=0) // and if the first letter is small
fputc(toupper(c),p); //change the small to capital
if(c=='.')
end_of_line=1;
else
end_of_line=0;
}
fseek( p, 0, SEEK_SET ); //setting the file pointer to the start of file
while((c=fgetc(p))!=EOF)
printf("%c",c);
fclose(p);
}