Pascal - How to pass variable number of parameters to a subprogram ? (variadic function)

前端 未结 1 945
天涯浪人
天涯浪人 2021-01-19 06:40

I recently had to face this problem, which is, how can I pass 1, 2, 3, 9, 38919, 0 or any random number of arguments to a function or a procedure in Pascal ? I want to make

相关标签:
1条回答
  • 2021-01-19 07:17

    First and for all, writeln is a language construct, and not a function. You can't imitate it for your own functions. (you can reroute writeln output though, and FPC has writestr that can writeln to string)

    The array of const syntax is more Delphi oriented. Open array is Delphi oriented too, but Turbo Pascal had a own form. It is only for one type though.

    But since classic pascal has no way of doing variadic parameters, if you want this, you can't avoid using extensions.

    0 讨论(0)
提交回复
热议问题