I have problem with combining the two function together.
For the first while statement, it only applicable for file redirection eg "programname < filename". If i use the first while statement for getting a standard input without the file redirection, the user have to press the control D button in order to exit the while statement.
As for the second while statement, the user able to enter the standard input manually and then press enter and it will exit the while loop. But for the file redirection, it is only able to get the first line in the file and not the whole file.
How can i implement a while statement where both the condition will be able to work which means when the user use the file redicrection, it is able to read till the end of the file and also when the user enter the input manually from the standard input and press enter, it will exit from the loop ??
Code:// used for file input redirection while((c = getchar()) != EOF) { } // used for command line input while((c = getchar()) != '\n') { }



LinkBack URL
About LinkBacks


