#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    86
    Rep Power
    0

    Post Print report problem


    i have a problem with my code it works when i click it twice .. before it print .. and how to add form feed in this code please help me thanks a lot ...


    main( )
    {
    FILE *funny, *printer;
    char c;
    funny = fopen("TENLINES.TXT", "r"); /* open input file */
    printer = fopen("PRN", "w"); /* open printer file */
    do {
    c = getc(funny); /* get one character from the file */
    if (c != EOF) {
    putchar(c); /* display it on the monitor */
    putc(c, printer); /* print the character */
    }
    } while (c != EOF); /* repeat until EOF (end of file) */
    fclose(funny);
    fclose(printer);
    }

    :tntworth: :tntworth: :tntworth:

    Comments on this post

    • ptr2void disagrees : Still no code tags. You're fairly hopeless.
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,417
    Rep Power
    1871
    It's a shame you can't yet use code tags (it's the # icon).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    86
    Rep Power
    0
    Originally Posted by salem
    It's a shame you can't yet use code tags (it's the # icon).
    but i used and i want to learn with that code sorry for what i done ..
    :chomp: :chomp: :tntworth: :tntworth:
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    Hilight the code portion of your post with your mouse, then press the # button.


    fputc(12,funny);

    char*string_with_one_form_feed = "\014";

    char ff_character = '\014';

    #define FF '\014'



    fprintf(funny,"%c",12);
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    86
    Rep Power
    0
    is this correct sir, that i put the form feed inside the loop and
    what i Add to this code bec. the printer is not work when you use this in first try then when you try it in 2nd time it will works ..


    main( )
    {
    FILE *funny, *printer;
    char c;
    funny = fopen("TENLINES.TXT", "r"); /* open input file */
    printer = fopen("PRN", "w"); /* open printer file */
    do {
    c = getc(funny); /* get one character from the file */
    if (c != EOF) {
    putchar(c); /* display it on the monitor */
    putc(c, printer); /* print the character */
    count++; // count row
    }
    ctr++; // count columns
    if (count == 62){
    fprintf(print,"%c",12); //* new page
    count = 1;
    }
    } while (c != EOF); /* repeat until EOF (end of file) */
    fclose(funny);
    fclose(printer);
    }


    ... :chomp: :chomp:
    thanks for your help ...

    :tntworth: :tntworth:
  10. #6
  11. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    Dear lhon12006;

    To use the printer these days I write LaTeX or a program to write LaTeX. pdflatex converts this to acrobat pdf, which prints beautifully. No longer do I worry about form feeds. Sure, back in about 1983 my girlfriend was responsible for a 4H program. I got our dot matrix device to print a crossword puzzle she created. On a few other occasions that era I got those printers to dance.

    Good luck with your programming studies!
    Dave.

    Comments on this post

    • lhon12006 agrees
    [code]Code tags[/code] are essential for python code and Makefiles!
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    86
    Rep Power
    0
    Originally Posted by b49P23TIvg

    Dave.
    thanks a lot sir for the time you keep answering the problem i need to be solve :rockon: :rockon:

IMN logo majestic logo threadwatch logo seochat tools logo