我刚开始使用qbasic中的文件处理。我写的程序总是显示错误"错误的文件模式"。请帮帮我!
OPEN "test.dat" FOR INPUT AS #1
CLS
INPUT "Enter username:"; a$
INPUT "Enter Password:"; b$
WRITE #1, a$, b$
CLOSE #1
END
答案 0 :(得分:3)
如果您希望WRITE
输出到文件,那么从逻辑上讲,您可能想尝试这样做:
OPEN "test.dat" FOR OUTPUT AS #1
CLS
'etc
答案 1 :(得分: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