Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In <code>getLine()</code>, when you give the <code>infile</code> <code>FILE*</code> to the <code>getNum()</code> function, you dereference it:</p> <pre><code> l=getNum(value,*infile); </code></pre> <p>But <code>getNum()</code> would just expect a normal <code>FILE*</code>, not a dereferenced one. So pass <code>infile</code> to that function unchanged:</p> <pre><code> l=getNum(value,infile); </code></pre> <hr> <p>Additionally, the <code>while(value != '\n')</code> loop will probably run forever, writing past the end of the <code>lines</code> array until you get a segmentation fault. <code>value</code>, which is controlling when the loop will terminate, is never modified (also it isn't initialized, making it start with an arbitrary value). The <code>getNum()</code> function, which probably is supposed to modify <code>value</code>, gets a <strong>copy</strong> of the integer passed as a parameter and then modifies this copy. The original <code>value</code> is never changed.</p> <p>If you want the function to change the <code>value</code> variable you have to use a pointer that points to <code>value</code> and that is used to modify that variable:</p> <pre><code>int getNum(int *value, ...) { *value = 5; ... } l=getNum(&amp;value, infile); </code></pre> <p>Also it is a little dubious that <code>value</code>, an integer variable, is assigned and compared against <code>'\n'</code>, a character literal. Are you sure you want to use the integer value of <code>'\n'</code> as a termination condition of your loop?</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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