I need to covert this code from a user input using gets() to scanning in an input txt file. It would also be helpful to find a way to count the number of letters in every word. Starting with 1 letter words and on.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main(void) {
int acount, bcount, ccount, dcount, ecount, fcount, gcount, hcount, icount, jcount, kcount, lcount, mcount, ncount, ocount, pcount, qcount, rcount, scount, tcount, ucount, vcount, wcount, xcount, ycount, zcount = 0;
char *str;
printf("Enter any string : ");
gets(str);
while (*str != '\0')
{
if(isalpha(*str))
{
toupper(*str);
switch(*str)
{
case 'A':
++acount;
break;
case 'B':
++bcount;
break;
case 'C':
++ccount;
break;
case 'D':
++dcount;
break;
case 'E':
++ecount;
break;
case 'F':
++fcount;
break;
case 'G':
++gcount;
break;
case 'H':
++hcount;
break;
case 'I':
++icount;
break;
case 'J':
++jcount;
break;
case 'K':
++kcount;
break;
case 'L':
++lcount;
break;
case 'M':
++mcount;
break;
case 'N':
++ncount;
break;
case 'O':
++ocount;
break;
case 'P':
++pcount;
break;
case 'Q':
++qcount;
break;
case 'R':
++rcount;
break;
case 'S':
++scount;
break;
case 'T':
++tcount;
break;
case 'U':
++ucount;
break;
case 'V':
++vcount;
break;
case 'W':
++wcount;
break;
case 'X':
++xcount;
break;
case 'Y':
++ycount;
break;
case 'Z':
++zcount;
break;
}//Close case
}//Close if
}//Close while
printf("Number of A's: %d", acount);
}