Capitalize first letter of every word in .txt file
Code:
#include <stdio.h>
#include <ctype.h>
int main(void)
{
FILE* fin;
FILE* fout;
char inputfname[256];
char outputfname[256];
char currentchar;
char previouschar = ' ';
printf("Enter the input filename\n");
scanf("%s", inputfname);
printf("Enter the output filename\n");
scanf("%s", outputfname);
fin = fopen(inputfname, "r");
fout = fopen(outputfname, "w");
while(!feof(fin))
{
currentchar = fgetc(fin);
if(!isalpha(previouschar) && isalpha(currentchar))
{
currentchar = toupper(currentchar);
fputc(currentchar, fout);
}
currentchar = previouschar;
}
system("PAUSE");
return 0;
}
As the title says. I can't get this to work. I know I'm making a stupid mistake somewhere and I can't find it. And yea I know system("PAUSE"); shouldn't be used but it's what my prof. insists on.