How to use index in the file name

前端 未结 4 1544
迷失自我
迷失自我 2021-01-24 09:12

This is probably trivial question. I am not a professional programmer, I am rather a mathematician who is doing some numerical experiment using C. I would like the output of my

4条回答
  •  猫巷女王i
    2021-01-24 09:31

    Use sprintf to generate the filename.

    char buf[80];
    sprintf(buf,"file%d", i);
    fopen(buf,"w");
    

    Array syntax in C uses square brackets [].

提交回复
热议问题