Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Oh boy !</p> <p>First what You are doing right or at least it seems so. You are drawing attention and get points for upvotes, despite the fact, that the code looks like typed in directly to the editor box on the Stackoverflow and never checked with any compiler. Good job :)</p> <p>Now what's wrong. The list is long but some tips</p> <pre><code>void main() { PERSON person[100]; int *total; funcB(people, &amp;total); } void funcB(PEOPLE people[], int *total); </code></pre> <p>It would be nice if You showed us the definitions of (probably) structs PEOPLE and PERSON. In the code we can see, there is no definition of people - the variable you pass to funcB. You define a pointer to int - total and don't initialize it. Then You pass an address of that pointer to funcB which takes int* not int** as a second argument. Those types are not compatible.</p> <pre><code>void funcB(PEOPLE people[], int *total) { int i; for (i = 0; i &lt; total; i++) { printf("%s\n", people[i].name); } funcA(people, &amp;total); } void funcA(PEOPLE people[], int *total) </code></pre> <p>You use a pointer in the loop condition instead of the value pointed too. There is no value, because You didn't initialize the pointer in main, but here You have incompatible types in the condition. You pass an address of the pointer to funcA instead of the pointer, like in main.</p> <pre><code>void funcA(PEOPLE people[], int *total) { FILE *fp; char line[100]; fp = fopen("example.txt", "r"); if (fp == NULL) { exit(1); } else { fgets(line, 100, fp); //get a number from the txt total = atoi(linha); //convert to int } } </code></pre> <p>You use an undefined symbol 'linha' - I guess it's a misspelling of 'line'. Then You assign an int to a pointer instead of an int pointed to by that pointer.</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. 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