Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In this code:</p> <pre><code>char ** get_wanted_g_matrix(int pocetradek /*number of lines*/) // get wanted g matrix { char ** string; printf("Zadejte hledanou matici:\n"); int i = 0; if(( * string = (char ** )malloc(100 * sizeof(char *))) == NULL) </code></pre> <p>You dereference <code>string</code>, but it is uninitialized, so you're writing to a random location in memory. Change that <code>* string</code> to just <code>string</code>. The same applies here:</p> <pre><code>if((* string = (char **)realloc(* string, 100 * ( i - 1 ) * sizeof(char *))) == NULL) </code></pre> <p>..and to the corresponding lines in <code>get_searched_g_matrix()</code> as well.</p> <p>In this line:</p> <pre><code> if((i &gt; 1) &amp;&amp; (*string[i-1] != strlen(*string[i]))) </code></pre> <p>You're passing a <code>char</code> to <code>strlen()</code>, when you should be passing a <code>char *</code>. I suspect you mean just <code>strlen(string[i])</code>, but that line seems somewhat nonsensical. The same problem is in <code>get_searched_g_matrix()</code> as well, as well as the first three calls to <code>strlen()</code> in <code>search()</code>.</p> <p>Your <code>get_searched_g_matrix()</code> can fall off the end without returning a value - you need to consider what to return if <code>feof(stdin)</code> is not true.</p> <p>In <code>main()</code>, your call to <code>search()</code> passes <code>char</code> values, but the function expects <code>char **</code>. You probably mean:</p> <pre><code>printf("Matice nalezena %d krat.\n", search( string1, string2 )); </code></pre> <p>(The above won't be sufficient to fix your code - you also appear to have some logic problems. But it's a necessary start.)</p> <p>In future, you should compile your code with a higher level of warnings enabled, then fix the problems that the compiler identifies (if you're using gcc, compile with <code>-Wall</code>).</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.
    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