printf - C: Cannot get fprintf to print to output-file -
i'm trying print matrix csv. arg[2] in file name , can verify works correctly since generate file not populate it. close file , try flushing not work.
// open output/second file , write contents of truncated dct matrix outputfp = fopen(argv[2], "w"); if (outputfp == null) { fprintf(stderr, "can't open output file %s!\n", argv[2]); exit(1); } double hold = 0; printf("test\n"); (i = 0, < idx; i++;) { (j = 0, j < array_width; j++;) { hold = test_write[i][j]; fprintf(outputfp, "%.61f", hold); if (j != array_width) { fprintf(outputfp, ","); } else { //continue; } fflush(outputfp); } } fclose (outputfp); return 0; }
this cycle
(j = 0, j < array_width; j++;) {
never iterates.
wrong placement of ,
, ;
makes j++
iteration condition. since before first iteration j++
evaluates 0
, cycle never entered. apparently, meant write
(j = 0; j < array_width; j++) {