C program runs to avoid re-entering values every time

suppose there is a c program that reads a character and then outputs

scanf("%c", &cha);
printf(%c", cha);

when running in this way, you have to type one character at a time. What I want to achieve is to fix this character in a file so that you don"t have to type it repeatedly each time, as long as you don"t change the above two lines of code.

C
Mar.28,2021

change the input and output stream:

< H1 > include < stdio.h > < / H1 >

int main () {

freopen ("in.txt", "r", stdin);

freopen ("out.txt", "w", stdout);
/ ) the code is written as is, and nothing needs to be modified /

fclose (stdin);
fclose (stdout);
return0;

}


use the input pipe | to resolve this problem.

take the linux system as an example, you can do this

echo -n <> | <>
-sharp 
echo -n hi | cat -
-sharp 
cat <> | <>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39a54-411ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39a54-411ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?