Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to use getchar() and redirect to input textfile in ASCI C programming. Hello, underneath is the code I did and it works where it

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

Hello, underneath is the code I did and it works where it counts and prints out upper and lower case of each letter. For instance, "Hello World", there are H=1, e = 1, l = 3..etc. However, my professor is asking to use getchar() and use 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Apache Cassandra 3 X An Expert Guide To Improving Database Scalability And Availability Without Compromising Performance

Authors: Aaron Ploetz ,Tejaswi Malepati ,Nishant Neeraj

3rd Edition

1789131499, 978-1789131499

More Books

Students also viewed these Databases questions