First off, your loop control is incorrect:
>fgets(buf, BUFSIZ, fp);
>while (buf[0])
You should do it this way
Code:
while (fgets(buf, BUFSIZ, fp) != NULL)
{
fprintf(printer, "%s", buf);
}
Now, how to print characters that represent a barcode.... Well, I suppose you could review the ASCII chart and find the appropriate characters, but I'm not sure they exist. Don't you require specific thickness of line and pitch?
Anyway, you could try something like this:
Code:
#define BAR_FOR_ZERO ' ' /* Space */
#define BAR_FOR_ONE '|' /* v-bar */
while ((c = fgetc(fp)) != EOF)
{
switch (c)
{
case '0': fputc(BAR_FOR_ZERO, printer); break;
case '1': fputc(BAR_FOR_ONE, printer); break;
default: /* Handle other chars here */ break;
}
}