I'm using SAMS Book "Teach Yourself "C" in 21 Days" sixth edition.

useing the Editor/Compiler that came with the Book. DEV C++

The saubject program that I'm trying to compile is Print_it.c

it prints files w/line numbers and when the compiler gets to the first

line with "STDPRN" it stops compiling and says Undeclared reference

I'm confused and don't have a clue how to fix this problem; inclosing

a listing of this Program.

/* print_it.c-This program prints a listing with line numbers! */
#include <stdlib.h>
#include <iostream.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, "\n inProper Usage is: " );
fprintf(stderr, "\n\nprint_it.c\n\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( stdio, "%4d:\t%s", line++,buffer );
}
fprintf(stdprt, "\f" );
fclose(fp);
return(0);
}
void do_heading(char *filename )
{
page++;
 
if ( page > 1)
fprintf( stdprt, "\f" );
 
fprintf( stdprt, "page: %d, %s\n\n", page, print_it.c );
}

any asstance would be appreciated.

Dick

delete line 3 -- that file (iostream.h) is for C++ programs, not C programs.

the compiler gets to the first

line with "STDPRN" it stops compiling and says Undeclared reference

That's because there's nothing said about "stdprn" in any of the #include header files that you have included.

In any case I don't see "stdprn" in the code that you provided.

But regardless, "stdprn" it used to work for MS-DOS but not windows NT or above.

I do see that stdprn is not defined or thire is no init for it. got this program out of a book.

do you know how I would assign a printer that is on LPT1 to stdprn?

Dick

I do see that stdprn is not defined or thire is no init for it. got this program out of a book.

do you know how I would assign a printer that is on LPT1 to stdprn?

Dick

I have that book can you tell me what day or chapter you got the code from?.

I found this link may be it can help

the name of the book is "teach yourself C in 21 days" the file is on page 26 listing T&R 1
file name is print_it.c

Dick

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.