八度:如何将变量放入fopen的文件名中

发布于 2025-01-20 07:32:04 字数 201 浏览 1 评论 0原文

我有一个变量,它是我的文本文件名称的一部分:

Test123_Variable.txt

现在我想使用函数 fopen 打开文本文件,但由于我的文件名取决于变量的名称,我不知道如何制作正确的语法:

这显然不起作用: filename = ("Test123_Variable.txt");

如何解决此问题?

I have a Variable which is part of the Name of my Textfile:

Test123_Variable.txt

Now I want to use the Function fopen to open the textfile, but since my Filename is dependent on the name of my variable I don't know how to make the right syntax:

This is obviously not working:
filename = ("Test123_Variable.txt");

How can I fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花坊 2025-01-27 07:32:04

如果我理解您的目标,

filename = ["Test123_" Variable ".txt"];

那应该做您期望的。例子:

>> Variable = "sample_1";
>> filename = ["Test123_" Variable ".txt"]
filename = Test123_sample_1.txt

If i understand right your purpose,

filename = ["Test123_" Variable ".txt"];

should do what you expect. Example:

>> Variable = "sample_1";
>> filename = ["Test123_" Variable ".txt"]
filename = Test123_sample_1.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文