Question: getchar() redirect to input textfile in ASCI C programming. Hello, underneath is the code I did and it works. However, my professor is asking to

getchar() redirect to input textfile in ASCI C programming.

Hello, underneath is the code I did and it works. However, my professor is asking to use getchar() and have an input text file to redirect it. How would i do that on my code? Thank you for the help.

#include #include int main() { char string[100]; int c = 0, Lcase[26] = {0}, x; int Ucase[26] = {0}; printf("Enter a string "); gets(string); while (string[c] != '\0') { if (string[c] >= 'a' && string[c] <= 'z') { x = string[c] - 'a'; Lcase[x]++; } if( string[c] >= 'A' && string[c] <= 'Z') { x = string[c] - 'A'; Ucase[x]++; } c++; } for (c = 0; c < 26; c++) { printf("%c occurs %d times in the string. ", c + 'a', Lcase[c]); } for (c = 0; c < 26; c++) { printf("%c occurs %d times in the string. ", c + 'A', Ucase[c]); } return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!