Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 不知道文件名的测试人员_C_Shell - Fatal编程技术网

C 不知道文件名的测试人员

C 不知道文件名的测试人员,c,shell,C,Shell,程序的一些测试用例的格式为:??。inans??。outin目录 /input和/output,这样对于每个测试,名称的第一部分是相等的,例如test1.in,test1.out 如何编写一个代码,将这些文件一起扫描?(可能是可以按字母顺序[在每个目录中]查找文件…)for(int i=0;i

程序的一些测试用例的格式为:
??。in
ans
??。out
in目录
/input
/output
,这样对于每个测试,名称的第一部分是相等的,例如
test1.in
test1.out

如何编写一个代码,将这些文件一起扫描?(可能是可以按字母顺序[在每个目录中]查找文件…)

for(int i=0;i<100;i++){
文件名[100]中的字符;
char out_文件名[100];
sprintf(文件名“./输入/测试%d.in”,i);
sprintf(输出文件名“./输出/测试%d.out”,i);
/*根据需要使用in_文件名和out_文件名*/
/* ... */
}

使用(和相关函数)获取目录中所有文件的列表,然后解析数组。

测试名称可以是
test3a。在
中,使用
%x
进行十六进制输出:-)要做什么:
test1.in
test2.in
test3a.in
,…+这些如何在shell中运行?
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 */
    /* ... */
}