版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32768743/article/details/87123018
package csapp
import kotlinx.cinterop.*
import platform.posix.*
fun main() {
val fd1 = open("foobar.txt", O_RDONLY, 0)
val fd2 = open("foobar.txt", O_RDONLY, 0)
val buffer = ByteArray(1024)
buffer.usePinned { pinned ->
read(fd1, pinned.addressOf(0), 1)
read(fd2, pinned.addressOf(0), 1)
println("c = ${buffer[0].toChar()}")
}
exit(0)
}
最后输出