Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C file functions in QB64 ???
#2
using the msvcrt.dll helps to avoid type clashes, and although it compiles, it crashes
Code: (Select All)
Type file
    ptr As _Offset 'zstring ptr
    cnt As Long
    bas As _Offset 'zstring ptr
    flag As Long
    file As Long
    charbuf As Long
    bufsiz As Long
    tmpfname As _Offset 'zstring ptr
End Type

Declare Dynamic Library "msvcrt"
    Function fopen%& (file_name As String, mode As String)
    Function fclose& (file_ptr As _Offset)
    Function fprintf& (file_ptr As _Offset, frmt As String, st As String)
End Declare

Dim As _Offset fp
Dim As String fln, md, frmt, text
Dim As Long status

'fp = _Offset(file)

fln = "fopen-test.txt" + Chr$(0)
md = "w" + Chr$(0)
frmt = "%s\n" + Chr$(0)
text = "hello world" + Chr$(0)

fp = fopen(fln, md)
Print "fp = fopen(fln, md) = "; fp
status = fprintf(fp, frmt, text)
status = fclose(fp)
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: 7 Guest(s)