Thread: stdprn

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    5

    printing to usb printer in c under xp

    I know this has been posted before, but I haven't found an answer for what I need.

    I am using Teach Yourself C in 21 Days 6th edition. There is a listing called stdprn, which I will list below. The listing is supposed to print (using the printer) out the listing of a program's code with line numbers and stuff.

    Code:
    /* print_it.c--This program prints a listing with line numbers! */
    #include <stdlib.h>
    #include <stdio.h>
    
    void do_heading(char *filename);
    
    int line = 0, page = 0;
    
    int main( int argv, char *argc[] )
    {
      char buffer[256];
      FILE *fp;
    
      if( argv < 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( stdprn, "%4d:\t%s", line++, buffer );
      }
    
      fprintf( stdprn, "\f" );
      fclose(fp);
      return 0;
    }
    
    void do_heading( char *filename )
    {
       page++;
    
       if ( page > 1)
          fprintf( stdprn, "\f" );
    
       fprintf( stdprn, "Page: %d, %s\n\n", page, filename );
    }
    On my old compiler, it wouldn't compile because stdprn wasn't defined. Now it does compile (on DJGPP), but when i run it all it does is sit there and then eventually display the command prompt without printing anything.

    I'd appreciate some assistance with this. Thanks a bunch.

    p.s. i am using windows xp and my printer is connected via USB
    Last edited by zack787; 01-14-2006 at 09:03 PM. Reason: left out info

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. newbie question dealing with an error
    By zack787 in forum C Programming
    Replies: 2
    Last Post: 02-27-2008, 04:49 PM
  2. undefine stdprn
    By pap in forum C Programming
    Replies: 2
    Last Post: 02-07-2003, 10:04 AM
  3. Undefined symbol 'stdprn'
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-03-2002, 02:05 PM