Pointer(s)^ versus s[1]

前端 未结 7 1125
南旧
南旧 2021-02-12 14:56

In a function that reads data (data meaning exclusively strings) from disk, which should I prefer? Which is better?

A) DiskStream.Read(Pointer(s         


        
7条回答
  •  半阙折子戏
    2021-02-12 15:18

    The second one (DiskStream.Read(s[1], Count)). Whenever you encounter an untyped var parameter it reads like "take the address of what is passed as a parameter". So in this case you are passing the address of the first character of the string s, which is what you intended to do.

提交回复
热议问题