Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>here's an alternative test code that works fine, take a loot at it and see if it helps. in addition, you can add </p> <pre><code>typedef struct node_t { struct node_t* next; char* value; } node; </code></pre> <p>this may appear simpler to understand, but it isn't because nature of typedef is confusing. I STRONGLY suggest you take a look at <a href="https://github.com/torvalds/linux/blob/master/Documentation/CodingStyle" rel="nofollow">https://github.com/torvalds/linux/blob/master/Documentation/CodingStyle</a> This is the coding style of the linux kernel, it is very short and simple, not particularly a law, but it is worth noting...</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; struct node_t { struct node_t* next; char* value; }; struct node_t* create(const char* istr) { struct node_t* ptr = (struct node_t*)malloc(sizeof(struct node_t)); char* tmp = (char*)malloc(sizeof(char) * (strlen(istr) + 1)); strcpy(tmp, istr); ptr-&gt;next = 0; ptr-&gt;value = tmp; return ptr; } struct node_t* remove(struct node_t* start, const char* value) { struct node_t* current = start; struct node_t* prev = start; while (current != 0) { if (!strcmp(value, current-&gt;value)) { if (current == start) { struct node_t* retval = current-&gt;next; free(current-&gt;value); free(current); return retval; } else { /* nothing happens */ return 0; } } } } int main(const int argc, const char** argv) { struct node_t* pt = create("1"); printf("%s\n", pt-&gt;value); pt-&gt;next = create("2"); printf("%s\n", pt-&gt;next-&gt;value); remove(pt, "1"); return 0; } </code></pre>
    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.
 

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