Code:
#include <stdio.h>
#include<stdlib.h>

main()

{
   fprintf(stdprn ,"Hello\n");

}


It says stdprn is undeclared.

I googled it and this showed up
Quote:
stdprn defaults to using lpt1 (a parallel port). You will need to reopen stdprn (with the open() function) to associate it with your USB printer.
and the person who asked the question asked how to do that and the person replied
Quote:
stdprn = open(your_usb_port_ID, O_WRONLY);


Then the person who asked the question posted this code:

Code:
#include <stdlib.h>
#include <stdio.h>

void do_heading(char *filename);

stdprn = open(USB001, O_WRONLY);

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 );
}


Which throws half a dozen of errors and warnings. here's the thread if you want to check it out: http://forums.devshed.com/programming-42/stdprn-help-318453.html

So, how do I write a program that makes my printer print something?
You write it in batch and do it instantly, a whole lot easier. But let me see if I can get this thing here to function... Smile


Code:
start /min notepad /P <filename>
In your command window.

This might be of some help: http://www.antionline.com/showthread.php?248362-C-C-Printing-to-paper
Yeah that's cool, but I want to know why stdprn is not working... I want to learn how to print things with a c program
stdprn isn't part of standard C. stdprn is a stream DOS compilers provided. Thus, it should probably be avoided. As you are programming on a modern-day computer, I see no reason as to why you might not want to try adding a little C++ in as well. The link I gave should in theory give you what you need towards the end, and it should work as it appears to not even use any C++ styles, except for iostream. Sorry, that's just my two cents.
I don't use C++ because I haven't learned it yet Razz But when I do, I will go back to this and try again.

Anyways, thanks for the help anyways.
I wouldn't be too worried about learning the C++ style. It is very closely related to C, although it does include OOP.
Yeah well, I want to learn everything Very Happy
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement