Note that there are some explanatory texts on larger screens.

plurals
  1. POfscanf failing in this C code
    primarykey
    data
    text
    <p>So being a new intern, I need to fix a lot of dirty code that some of these people wrote. Heres a snippet and I'm having a little issue figuring out what is the precise issue:</p> <pre><code>for (i=0; i&lt;TOOL_LIMIT; i++) { if ( 0 &gt;= fscanf(fp,"%s %s %s %s %s %s %s\n",coreData[i][0],\ coreData[i][1],coreData[i][2],coreData[i][3],coreData[i][4],coreData[i][5], coreData[i][6])) { break; } totalCases++; } fclose(fp); </code></pre> <p>Basically, fp is opened to some file that has the following regex pattern:</p> <pre><code>data11 data12 data13 data14...data17 data21 data22 data23 data24...data27 ... </code></pre> <p>I feel like this code isn't working the way it's intended too. Basically, its suppose to read each line of the file, and fill in the array coreData as shown. I don't think fscanf works like it's being shown here, but I could be wrong. Is this code working as it should? I haven't done file io with c in a while.</p> <p>Edit;; Sorry, should give a brief overview of failure. Basically, the C-script is a cgi script that takes in some inputs (files that have errors) and matches those files to the data in the file opened by fp (call it 'fp_file'), and generates an html table. If the file with the error shows up in the fp_file, then it prints some extra information (like data12 etc), otherwise it leaves the entry in that table blank. Example File f01 was found to have an error we now check fp for 'f01', if it exists, we show some more information about that file (author, etc).</p> <p>What I am seeing is that only one file is being matched up correctly (the first line of fp). Other than that, a blank space is in place for the rest of the error files.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload