No. You typically would not have hard-wired data like this program has.
Here is a new problem:
Problem: Write a program that reads characters from standard input and writes characters to standard output. Each alphabetic character should be a capital letter on output.
Usually standard input is the keyboard and standard output is the monitor. The flowchart has been modified to match this new problem.
The grain size of this problem is (again) single characters.
The input/output functions used should match the grain size.
getchar()
reads single characters from standard input.
int getchar()
return the next character from the input stream as the low-order byte of an int. The function returns the character or EOF when End Of File is reached.
The constant EOF
is defined in the header file stdio.h
as a 32-bit pattern,
usually 0xFFFFFFFF (all 1-bits).
This is because all 8-bit patterns are legitimate values that might be read from a file and getchar()
might easily return
any of them.
getchar()
works with binary files, not just text file.
It is a common mistake to try to use char
variables with getchar()
and putchar()
.
This will not always work.
Is the new flowchart structured?