@Kernelpanic
I think I know why you are having a problem, you must be using the 32-bit version of QB64
if that's the case then try the code below
for 32-bit QB64
I think I know why you are having a problem, you must be using the 32-bit version of QB64
if that's the case then try the code below
for 32-bit QB64
Code: (Select All)
Declare Dynamic Library "msvcrt"
Function fopen%& (file_name As String, mode As String)
Function fclose& (ByVal file_ptr As _Offset)
Function fprintf& (ByVal file_ptr As _Offset, frmt As String, st As String)
Function fread~& (buff As String, Byval size As _Unsigned long, Byval count As _Unsigned long, Byval file_ptr As _Offset)
End Declare
Dim As _Offset fp
Dim As String fln, md, frmt, text
Dim As Long status
fln = "fopen1-test.txt" + Chr$(0)
md = "w" + Chr$(0)
frmt = "%s" + Chr$(13) + Chr$(10) + Chr$(0) '\n didn't work but + Chr$(13) + Chr$(10) does work
text = "hello world" + Chr$(0)
fp = fopen(fln, md)
status = fprintf(fp, frmt, text)
status = fclose(fp)
md = "r" + Chr$(0)
text = Space$(64) + Chr$(0)
fp = fopen(fln, md)
status = fread(text, 1, 64, fp)
Print text