Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So the compiler output might look intimidating, but, as a beginner, the bit you care about is usually in English. This example is no exception:</p> <pre><code>Type and run 1.c: In function 'do_heading': Type and run 1.c:54: error: 'error_handler' undeclared (first use in this function) Type and run 1.c:54: error: (Each undeclared identifier is reported only once Type and run 1.c:54: error: for each function it appears in.) </code></pre> <p>It's telling you that <code>error_handler</code> is undeclared. It appears nowhere else in your program so there's no way you're able to use it here. Let's look at the line:</p> <pre><code>if ((stdout = fopen("PRT:","w")) == NULL) { printf ("Printer busy or disconnected\n"); error_handler; } </code></pre> <p>You should know that semicolons are one way to indicate the end of a statement and that good practice is to put just one statement on a line. Break it up:</p> <pre><code>if ((stdout = fopen("PRT:","w")) == NULL) { printf ("Printer busy or disconnected\n"); error_handler; } </code></pre> <p>Now it's obvious: you're just saying <code>error_handler;</code>; it's not doing anything, it's not a function call (no parentheses), not a variable you're assigning to or reading from so it's clearly a huge fat error. Delete it and try again.</p> <p>By the way, if the line appeared in the book exactly as you've put it here - with two semicolons on a line - then yes, you should throw it on the fire. Read Kernighan and Ritchie's "The C Programming Language" and do all the exercises in it - you will be amazed how quickly you go from knowing nothing to being ready to work on real programs.</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.
 

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