Note that there are some explanatory texts on larger screens.

plurals
  1. POError_handler… what?
    primarykey
    data
    text
    <p>I'm trying to learn some C and have chosen to use the book "SAMS Teach yourself C in 21 days". (<i> btw is there any good C book at all? This is my third! I always end up with bad or broken code that is supposed to work and hit a wall in my learning process when it doesn't! :-( </i> ) Sadly I've run upon the code underneath that I just should type in and run. The typing went well but the running... well, not so well! The compiler gives me an error about this line: </p> <pre><code>{ printf ("Printer busy or disconnected\n"); error_handler; } </code></pre> <p>when I try to run this code. And since I'm VERY MUCH a novice when it comes to C coding, I have NO IDEA at all what to do, when the editor returns an error messages like this:</p> <pre><code>"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf rm -f -r build/Debug rm -f dist/Debug/GNU-MacOSX/type_and_run CLEAN SUCCESSFUL (total time: 158ms) "/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf "/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/type_and_run mkdir -p build/Debug/GNU-MacOSX rm -f build/Debug/GNU-MacOSX/Type and run 1.o.d gcc -c -g -MMD -MP -MF build/Debug/GNU-MacOSX/Type and run 1.o.d -o build/Debug /GNU-MacOSX/Type\ and\ run\ 1.o Type\ and\ run\ 1.c i686-apple-darwin10-gcc-4.2.1: and: No such file or directory i686-apple-darwin10-gcc-4.2.1: run: No such file or directory i686-apple-darwin10-gcc-4.2.1: 1.o.d: No such file or directory 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.) make[2]: *** [build/Debug/GNU-MacOSX/Type and run 1.o] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 158ms) </code></pre> <p>All I can understand is that "error_handler" is undeclared and that it does not seem to be a library function. SIGH!</p> <p><b><br> So said short, is there anything I can do to modify the code so it will work as intended and I can move on? </b> </p> <p>Or should I just throw the book over in the pile of useless books about C?</p> <p>Here is the code in its full length:</p> <pre><code>void do_heading(char *filename); int line = 0, page = 0; int main(int argv, char *argc[]) { char buffer[256]; FILE *fp; if (argv &lt; 2) { fprintf(stderr, "\nProper Usage is: " ); fprintf(stderr, "\n\nprint_it filename.ext\n"); return (1); } if ((fp = fopen(argc[1], "r")) == NULL) { fprintf(stderr, "Error opening file, %s!", argc[1]); return (1); } page = 0; line = 1; do_heading(argc[1]); while( fgets( buffer, 256, fp ) != NULL ) { if( line % 55 == 0 ) do_heading(argc[1]); fprintf( stdout , "%4d:\t%s", line++, buffer ); } fprintf( stdout , "\f" ); fclose(fp); return 0; } void do_heading(char *filename) { page++; if (page &gt; 1) fprintf( stdout , "\f"); fprintf( stdout, "Page: %d, %s\n\n", page, filename); if ((stdout = fopen("PRT:","w")) == NULL) { printf ("Printer busy or disconnected\n"); error_handler; } } </code></pre>
    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.
 

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