作者henry8168 (番薯猴)
看板C_and_CPP
标题[问题] C 语言能像 Python 一样写段落文章吗?
时间Fri Oct 12 13:23:05 2018
Python 有个很神奇的功能,就是注解能被直接拿来输进变数。
例如
text="""Hello,
world."""
我现在想写一个 function 的 help,
想说有没有类似的作法能写进去,
而不需要一大堆的 \n 来排版?
谢谢。
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 60.248.17.229
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1539321789.A.21F.html
※ 编辑: henry8168 (60.248.17.229), 10/12/2018 13:23:30
1F:→ aiwhat: #1Rko-g7E 推文有提到 raw string 10/12 13:42
这好像只有 C++ 才支援 囧"??
2F:→ testPtt: 看工具 类似__attribute__ 的东西 10/12 13:48
※ 编辑: henry8168 (60.248.17.229), 10/12/2018 14:07:28
3F:→ kdjf: 痾... python那个是multi line string不是注解 10/12 14:34
4F:→ kdjf: 只是fucntion def的第一个没被接收的string会被当help 10/12 14:35
5F:→ uranusjr: 你搞错很多事情, 不过答案是没有, 需要额外的工具来解析 10/12 15:11
6F:→ aiwhat: 抱歉没注意到是C 10/12 20:00
7F:→ aiwhat: #define str(s) #s 这个呢? 10/12 20:01
8F:→ aiwhat: 我好像搞错了… 10/12 20:02
9F:→ Bencrie: 不然就另外写成 .txt 然後包进 binary 当 resource? 10/12 21:37