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++) { 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo