Note that there are some explanatory texts on larger screens.

plurals
  1. POProgram works fine with VS2012 but encounters Error when using Tiny C
    primarykey
    data
    text
    <p>I was wondering what function will I need to copy the data of a <code>typedef struct</code> pointer into <code>typedef struct</code> array.</p> <pre><code>typedef struct nodebase{ char company[254]; int counter; int rows; int column; struct nodebase *next; }data; </code></pre> <p>I know that I could use <code>memcpy</code> for the <code>char company</code> but how about for the Integer values?</p> <p>I want to do something like:</p> <pre><code>int main() { data *p; data item[] = {0}; int counter = 0; /*Calling for the roster file to scan and store the data into `data *p` using fscanf*/ /*Code for singly linked-list*/ counter++ //This happens everytime the program has scanned 4 variables in the file item[counter] = p; //This definitely is now working.. </code></pre> <hr> <p>Edited: I am now using <code>memcpy</code> and the previous problem has been solved. </p> <p>(Thank you for your answers!)</p> <p>Now, I am encountering a new problem and that is in my singly linked-list.</p> <p>Apparently, there are 12 "counter" in the roster file (That means, there are 48 variables in the roster file to read and store the data).</p> <pre><code>//Code for Singly Linked-list int main() { data *p; data *head; data *tail; data item[] = {0}; FILE *f; int counter = 0; head = NULL; tail = NULL; while(!feoe(f) { p = malloc(sizeof(data)); /*Opens the roster file and Read &amp; Store the data in the file to the respective variables inthe `typedef struct`.*/ if(head ==NULL) { head = p; } else { tail-&gt;next = p; } tail = p; if(head!=NULL) { do{ printf(":||%s||: Name",p-&gt;name); //Just to check if the linked list is working memcpy(&amp;item[counter], p, sizeof(data*)); counter++; p = p-&gt;next; p = NULL; }while(p!=NULL); }free(p); } } </code></pre> <p>Problem: When printing each names of the 12 "sets" from the roster file, the program prints the first 10 sets correctly then it suddenly stops working. (Using Tiny C on Windows)</p> <p>And the bizzare thing is, when I compile this file with VS2012, it works fine.</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.
 

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