如何将文本打印到文件? C ++ [英] How Do I Print Text To A File? C++
本文介绍了如何将文本打印到文件? C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨我有一个问题,当我尝试写一个.txt文件我得到这个:
>错误期望FILE之前的初始化程序和错误预期的构造函数,解构函数,或者之前键入转换(令牌
i试图将其排除在函数之外但是存在相同的错误< br $>
int printname()
FILE * f
f = fopen( name.txt,r);
fprintf(f,歌曲:%s \ n,文件名);`
我该怎么办?
Hi i have a problem when i try to write a .txt file i get this:
> error expected initializer before FILE and error expected constructor, deconstructor, or type the conversion before ( token
i tried to put it out of the function but there is the same error
int printname()
FILE *f
f = fopen ("name.txt", "r");
fprintf(f, "Song :%s\n", filename);`
what can i do?
推荐答案
你的解决方案:学习语言!
当然我可以给你一个有效的代码但是它几乎涉及重写所有这些代码。这将使它成为一个神奇的解决方案。
我看到你几乎不知道该语言的语法。这段代码有更多的错误。
所以我的建议对你来说会更有成效:
- 阅读文档,手册,书籍......
- Google是你的朋友。
- 按照教程,你可以找到关于任何方面的教程语言。
- 滥用调试器看你的代码是否正在运行以及每次出现运行时错误。
没有捷径知识,不要跳过步骤。
编程是细节的艺术,掌握这门艺术需要时间。
Your solution: Learn the language !
Sure I could have give you a working code but it almost involve rewriting all this code. It would make it a magic solution.
I see that you barely know the syntax of the language. There is more errors that lines is this piece of code.
So I have an advice that will be more productive for you:
- read documentation, manuals, books ...
- Google is your friend.
- follow tutorials, you can find tutorials about any aspect of the language.
- Abuse of debugger to see your code running and every time you get a runtime error.
There is not short cut to knowledge, don't skip steps.
Programming is the art of details, and it takes time to master this art.
这篇关于如何将文本打印到文件? C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文