954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Learning "C"

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

CRD
Light Poster
31 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

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

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
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.

Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
 

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

CRD
Light Poster
31 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 
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

Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
 

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

CRD
Light Poster
31 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You