Using C to print to Canon ip1000 (USB)

This is a discussion on Using C to print to Canon ip1000 (USB) within the C Programming forums, part of the General Programming Boards category; Hi, I'm student doing my project... using Dev C++ as the software and writing a system with C. My task ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    1

    Using C to print to Canon ip1000 (USB)

    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:
    Attached Images Attached Images  

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merging linked lists
    By scwizzo in forum C++ Programming
    Replies: 15
    Last Post: 09-14-2008, 05:07 PM
  2. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 07:26 PM
  4. What kind of programs should I start writing?
    By Macabre in forum C++ Programming
    Replies: 23
    Last Post: 04-12-2003, 08:13 PM
  5. Printers On USB
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-10-2002, 10:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21