【发布时间】:2016-10-25 03:50:14
【问题描述】:
我有这个代码:
105 void draw_detections(char * image_file_name, image im, int num, float thresh, box *boxes, float **probs, char **names, image *labels, int classes)
106 {
107 int i;
108 FILE * fptr;
109 char filename[100];
110 strcpy(filename,"output/");
111 strcpy(filename,image_file_name);
112 strcpy(filename, ".txt");
113 printf(filename);
115 fptr = fopen (filename, "wb");
116 printf(fptr);
118 if (fptr == NULL) {
119 fprintf(stderr, "Can't open input file in.list!\n");
120 exit(1);
122 }
123 for(i = 0; i < num; ++i){
124 int class = max_index(probs[i], classes);
125 float prob = probs[i][class];
126 if(prob > thresh){
127 //int width = pow(prob, 1./2.)*30+1;
128 int width = 8;
129 printf("%s: %.0f%%\n", names[class], prob*100);
130 fprintf(fptr, "%s,%.0f%%\n", names[class], prob*100);
完整的代码可以在这里找到:https://gist.github.com/eba1a5a6373b688b1b5d36624c897b90 fptr 不为空,但没有创建文件。我该如何解决?
$ ls output/
什么都不返回! 注意:此行正确打印在标准输出上:
129 printf("%s: %.0f%%\n", names[class], prob*100);
【问题讨论】:
-
我想你有一个
.txt文件... -
看看
strcpy函数定义 -
文件名几乎打印正确,除了它从文件名的开头省略了 output/ 但是它甚至没有在当前目录中创建文件
标签: c file printf file-handling filehandle