Hi,
> i can print a string into a printer,for example
>
[quoted text clipped - 3 lines]
>
> But now i want to print a txt file into a printer, what should i do?
It's easy, but requires some more development. Look into the example source
below:
FILE* prnOut = fopen("LPT1", "wt"); // using as 'text'
FILE* txtIn = fopen("MyTextfile.txt", "rt"); // using cr-lf translation
// do some testing here that both files realy are opened:
if ((!prnOut) || (ferror(prnOut)) || (!txtIn) || (ferror(txtIn)))
{
if (prnOut) fclose(prnOut);
if (txtIn) fclose(txtIn);
return;
}
int hasread;
char buf[2048]; // 2KB bufsize
while ((!ferror(prnOut)) && (!ferror(txtIn)) && (!feof(txtIn)))
{
hasread=fread(buf, sizeof(char), 2048, txtIn);
if (fwrite(buf, sizeof(char), hasread, prnOut) != hasread)
break; // properly an error occured...
}
//...
Good luck!