Pascal 中字符串的格式化输入

formatted input from string in Pascal

在 Pascal(Delphi、Lazarus)中,有 Format() 函数用于从变量列表创建格式化字符串。它的工作方式类似于 C/C++.

中的 sprintf() 函数

另一方面,我不知道有任何函数会像 sscanf()C/C++ 中那样使用格式化字符串设置变量。 我错过了什么?你会如何达到类似的效果?

Free Pascal 有一个简单的 sscanf and a special scandatetime to reverse date format strings (formatdatetime 相反)

据我所知,这些例程也应该与 Delphi 一起工作,最糟糕的是标记修改。

请注意,还有 writestr and readstr 更像格式化的 I/O 概念,类似于 write/readln 但随后是 to/from 字符串。这些是编译器内置的,因此不适用于 Delphi