Hi, I'm student doing my project... using Dev C++ as the software and writing a system with C.

My task is to write a program that get line from user, and after the user press the enter key, it will automatically print the line into the printer... means the printer is printing out a paper...

the printer i'm using is Canon ip1000, the USB cable type.

i'd setup also my network pc name as 'mypc' and the share printer named as 'CanonPix'

here's so far what i'd done:

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

int main(int argc, char *argv[])
{
    char printText[255];
    int i = 0;
    
    printf("-------------------------\n");
    printf("Welcome to PC-Type Writer\n");
    printf("-------------------------\n");
    printf("* To quit, type '#' and press enter key! *\n\n");
    printf("System starts...\n");
    gets(printText);
    
    while(strcmp (printText, "#") != 0){       
      printer(printText);
      gets(printText);
    };
    printf("\nYou had quit the system! Good bye~\n\n");
    system("PAUSE");
}

int printer(char printText[255]){
    
  FILE *stream;
    
    system("NET USE LPT1 /d");  // free up the port
    system("net use LPT1 \\\\Mypc\\CanonPIX");
  
  if ((stream = fopen("LPT1", "w")) == NULL)
  {
    system("NET USE LPT1 /d");
    printf("printer not available\n This line is not printed:\n");
    printf(printText);
    printf("\n");
    return 0;
  }
  stream = fopen("LPT1", "w");
  printf("preparing to print\n");
  fprintf(stream, printText);
  fclose(stream);
  system("NET USE LPT1 /d");
  return 0;
    
}
i tried to connect the printer through the network, since the DOS cannot directly get to the USB type printer....

and here's the output came out: