gpt4 book ai didi

lisp - 如何将相似的显示(printf)写入方案中的文件?

转载 作者:太空宇宙 更新时间:2023-11-03 19:01:15 24 4
gpt4 key购买 nike

使用 TinyScheme。

我正在将我的代码写入文件(此处已解决 50%:How to write to a file in tinyscheme?):

(with-output-to-file "biophilia.c"
(lambda ()
(write code)
))
; and segmentation fault comes here

但它用 ""引号和\n\r 编写我的代码,所以它不会将其转换为换行符。

我需要编写看起来像 (显示代码)

的代码

racket docs 中的示例为例有 printf,但似乎 TinyScheme 实现没有 printf,也许我需要发现(添加它的代码)printf?

最佳答案

你可以试试:

(call-with-output-file "biophilia.c" 
(lambda (port)
(write-string code port)))

假设“代码”是一个字符串。它将删除任何转义,并将其写为纯文本。

关于lisp - 如何将相似的显示(printf)写入方案中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10909278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com