开发者

a tester which does not know the names of files

There are some test cases for a program in format: ??.in ans ??.out in directories ./input and ./output such that for each test the first part of the names are equal e.g. test1.in, test1.out

How can I write a code which sweeps through these files together? (may be the files can be looked for in alphabe开发者_如何学运维tical order [in each directory]...)


Get list of all files in a directory using opendir (and related functions), and then parse the array.


for (int i = 0; i < 100; i++) {
    char in_filename[100];
    char out_filename[100];

    sprintf(in_filename, "./input/test%d.in", i);
    sprintf(out_filename, "./output/test%d.out", i);
    /* use in_filename and out_filename as you see fit */
    /* ... */
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜