Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>params</code> is an <code>int [2]</code>, which decays to an <code>int *</code> when passed to a function, and functions that take <code>int []</code>s as parameters are really taking <code>int *</code>s behind the scenes. Unfortunately, <code>&amp;params</code> is an <code>int(*)[2]</code>, which is closer to an <code>int *</code> than the <code>int **</code> (same as <code>int *[]</code> in a function parameter) you need.</p> <p>Your best option is to change your function to:</p> <pre><code>double strcmp95(char *ying, char *yang, long y_length, int *ind_c) </code></pre> <p>And assume that the caller willl always pass an <code>int[2]</code>. Or you can explicitly ask for an <code>int(*)[2]</code> - a pointer to an array of 2 <code>int</code>s:</p> <pre><code>double strcmp95(char *ying, char *yang, long y_length, int (*ind_c)[2]) </code></pre> <p>But this seems unnecessary to guarantee that two <code>int</code>s are passed, and if you need to account for the possibility of more than two <code>int</code>s in the array is unsuitable. A better way is:</p> <pre><code>double strcmp95(char *ying, char *yang, long y_length, int *ind_c, size_t len) </code></pre> <p><code>size_t</code> is an unsigned integer type guaranteed to be able to hold the size of any object or any array index, and in this case the <code>len</code> parameter is the length of your array (<code>(sizeof params / sizeof params[0])</code> if you want to be fancy/forward thinking, <code>2</code> if you don't). That's the safest route.</p> <p>By the way, your <code>y_length</code> parameter should also be a <code>size_t</code> variable. <code>long</code> is signed, and I'd hate to have to handle a string of -1 length. Even if you use <code>unsigned long</code>, there's no guarantee that <code>long</code> will be sufficient to handle a system's sizes (or, conversely, that an errantly large <code>long</code> value will be too big for your system to handle and cause confusion).</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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