My code below converts whole letters of the text to uppercase letters. However, I need to capitalize each word from the file without using arrays, function and etc. Using ASCII.
poem.txt:
The house cat sits
And smiles and sings
He knows a lot
Of secret things
My code:
#include <stdio.h>
int main()
{
FILE *input;
FILE *output;
input = fopen ("poem.txt", "r");
output = fopen ("poem_modified.txt", "w");
if (input == NULL || output == NULL)
{
printf("Problem! \n");
return 1;
}
int ch;
while((ch=getc(input)) != EOF)
{
if( ch >= 'a' && ch <= 'z' )
{
ch = ch - 32;
}
fprintf(output, "%c", ch);
}
fclose(input);
fclose(output);
}