C file functions in QB64 ???
#8
@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
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
Reply


Messages In This Thread
C file functions in QB64 ??? - by Jack - 04-26-2023, 11:00 AM
RE: C file functions in QB64 ??? - by Jack - 04-26-2023, 11:34 AM
RE: C file functions in QB64 ??? - by DSMan195276 - 04-26-2023, 01:16 PM
RE: C file functions in QB64 ??? - by Petr - 04-26-2023, 01:25 PM
RE: C file functions in QB64 ??? - by Jack - 04-26-2023, 02:25 PM
RE: C file functions in QB64 ??? - by Kernelpanic - 04-28-2023, 05:02 PM
RE: C file functions in QB64 ??? - by Jack - 04-28-2023, 05:51 PM
RE: C file functions in QB64 ??? - by Jack - 04-28-2023, 06:50 PM
RE: C file functions in QB64 ??? - by Ultraman - 04-28-2023, 07:04 PM
RE: C file functions in QB64 ??? - by Kernelpanic - 04-28-2023, 07:50 PM
RE: C file functions in QB64 ??? - by DSMan195276 - 04-29-2023, 02:16 AM
RE: C file functions in QB64 ??? - by Kernelpanic - 04-29-2023, 06:58 PM



Users browsing this thread: 1 Guest(s)