【问题标题】:How to change name of a file or even a array in a static name parameter?如何在静态名称参数中更改文件甚至数组的名称?
【发布时间】:2015-10-27 11:24:45
【问题描述】:

我有:

sscanf(string1, "%d", &aux);
sscanf(string2, "%d", &aux);
sscanf(string3, "%d", &aux);
sscanf(string4, "%d", &aux);

我想要这样的东西:

for (int i = 1; i <= 4; i++)
sscanf(string<i>, "%d", &aux);

有办法吗?

P.S.:我给出了一个字符串示例,但我想对所有具有静态名称的东西都这样做,比如文件。

【问题讨论】:

  • 为什么不使用二维数组?
  • 例如,我不能使用 2d 文件。
  • 你要说的文件指针。
  • 这对我有帮助。不是我想要的,但我认为我可以做到。谢谢。

标签: c++ c file iteration


【解决方案1】:

你不能。语言不是按照您的思维方式设计的。但是你可以通过使用数组来解决你的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-27
    • 1970-01-01
    • 1970-01-01
    • 2022-11-20
    • 1970-01-01
    • 1970-01-01
    • 2022-06-23
    • 1970-01-01
    相关资源
    最近更新 更多