I am doing Kernighan/Ritchie ANSI C Second Edition exercises in the first chapter. Problem is, the book didn't teach you yet about argv/argc or fopen, yet it uses such a structure where if you just run your program and give input at runtime, you will get into an infinite repetition of the test (c = getchar()) != EOF because getchar() at runtime will prompt the user for input as soon stdin is empty, and when the user gives input, the input will process, and getchar() will prompt for another input. EOF will literally never get encountered.
My mentors told me that you can input an EOF with ctrl+d, but that is obviously a hack and not intended.
Another solution they gave me is a.out <<< "some string" which actually works and does have EOF, but now I am at a point where I have to have an input of multiple lines, and I have no idea how to input lines like this, and frankly I heard that <<< didn't even exist in 1989.
Here is a code example of the type of problem:
#include <stdio.h>
/* count characters in input; 1st version */
int main()
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
}
So how did programmers feed input in this kind of program back in the day? Mind you, you are only allowed to use the things the book taught you until now (which is literally nothing about input)