Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/Variadic-function/FreeBASIC/variadic-function-1.basic
Normal file
39
Task/Variadic-function/FreeBASIC/variadic-function-1.basic
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
' version 15-09-2015
|
||||
' compile with: fbc -s console
|
||||
|
||||
Sub printAll_string Cdecl (count As Integer, ... )
|
||||
Dim arg As Any Ptr
|
||||
Dim i As Integer
|
||||
|
||||
arg = va_first()
|
||||
For i = 1 To count
|
||||
Print *Va_Arg(arg, ZString Ptr)
|
||||
arg = va_next(arg, ZString Ptr)
|
||||
Next i
|
||||
End Sub
|
||||
|
||||
' ------=< MAIN >=------
|
||||
' direct
|
||||
printAll_string (5, "Foxtrot", "Romeo", "Echo", "Echo", "BASIC")
|
||||
|
||||
' strings
|
||||
Print : Print
|
||||
Dim As String a = "one", b = "two", c = "three"
|
||||
printAll_string (3, a, b, c)
|
||||
|
||||
' count is smaller then the number of arguments, no problem
|
||||
Print : Print
|
||||
printAll_string (1, a, b, c)
|
||||
|
||||
' count is greater then the number of arguments
|
||||
' after the last valid argument garbage is displayed
|
||||
' should be avoided, could lead to disaster
|
||||
Print : Print
|
||||
printAll_string (4, a, b, c)
|
||||
Print
|
||||
|
||||
' empty keyboard buffer
|
||||
While InKey <> "" : Wend
|
||||
Print : Print "hit any key to end program"
|
||||
Sleep
|
||||
End
|
||||
Loading…
Add table
Add a link
Reference in a new issue