1

我只是从 qbasic 中的文件处理开始。我编写的程序总是显示错误“错误文件模式”。请帮我!

OPEN "test.dat" FOR INPUT AS #1
CLS
INPUT "Enter username:"; a$
INPUT "Enter Password:"; b$
WRITE #1, a$, b$
CLOSE #1
END
4

2 回答 2

3

如果你想WRITE输出到一个文件,那么从逻辑上讲,你可能想试试这个:

OPEN "test.dat" FOR OUTPUT AS #1
CLS
'etc
于 2016-09-19T19:14:02.350 回答
1

Qbasic 中一个更具描述性的文件访问示例:

' input data and write to file:
OPEN "test.dat" FOR OUTPUT AS #1
INPUT "Enter Username:"; a$
INPUT "Enter Password:"; b$
WRITE #1, a$, b$
CLOSE #1
' open file for input and display data:
OPEN "test.dat" FOR INPUT AS #1
INPUT #1, a$, b$
PRINT "Username: "; a$
PRINT "Password: "; b$
CLOSE #1
END
于 2016-11-11T02:38:53.067 回答