【问题标题】:how to print consloe output into some .txt file in c如何将控制台输出打印到c中的某个.txt文件中
【发布时间】:2015-06-18 09:33:56
【问题描述】:
Min Profile Cycles  [215914]
Max Profile Cycles  [934625]
Max Profile         [23]
Max Profile Count   [4]

如何将所有这些控制台输出打印到 c 中的某个 .txt 文件中,以便每当我调用该函数时,它都会打印在 txt 文件中,而不是在控制台中打印。

【问题讨论】:

标签: c


【解决方案1】:

因为你的标签是 C,你可以在附加模式下 fopen() 一个文件,而不是使用 printf() 你使用 fprintf() (和 fwrite() 和类似的)这个文件句柄。

【讨论】:

  • 基本上在我的情况下,由于内存限制,prinf 被禁用,在这种情况下如何打印 valyes。
【解决方案2】:

一种简单的方法是在你的 shell 中写这样的东西:

$./a.out > hello.txt

【讨论】:

    猜你喜欢
    • 2021-06-20
    • 2021-06-05
    • 2022-12-04
    • 1970-01-01
    • 2020-04-24
    • 2016-11-28
    • 1970-01-01
    • 2012-06-01
    • 2023-03-16
    相关资源
    最近更新 更多