當調用scanf()時,我輸入Ctrl-D(EOF),然後忽略下一個scanf。 #include <stdio.h>
int main()
{
int input;
scanf("%d", &input);//I press Ctrl-D when this line
scanf("%d", &input);//this line just passed. n
我測試了下面的代碼與一些數據,該列表在for循環內工作正常。但在for循環之後,該列表不包含任何內容。怎麼來的?我需要列表在程序內部進一步使用,所以我不能用鍵盤手動中斷它。 l = []
for line in sys.stdin:
if line == '':
l.append([])
else:
new_list = [int(i) for i
我目前正在編寫一個DOS程序。在這個程序中,我使用服務21/AH=01從標準輸入中讀取一個字符。但是,似乎在從文件重定向標準輸入時,EOF檢測無法按預期工作。我在NASM語法寫了這個示例程序來說明這個問題: org 0x100
; read characters and sum them up
main: xor bx,bx
.1: mov ah,1
int 0x21
$ echo "Your code is bad and you should feel bad" > "<stdin>"
$ python
Python 3.6.0 (default, Dec 28 2016, 19:53:26)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "cre