Ask question about fprintf function

This is a discussion on Ask question about fprintf function within the C Programming forums, part of the General Programming Boards category; Ask question about fprintf function I want to ask about this source code ************************************ for (bitm=16;bitm>=0;--bitm) { outbit(outp,(bitpattern&(1<<bitm)) ? 1 ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    68

    Ask question about fprintf function

    Ask question about fprintf function

    I want to ask about this source code

    ************************************
    for (bitm=16;bitm>=0;--bitm)
    {
    outbit(outp,(bitpattern&(1<<bitm)) ? 1 : 0);
    }
    ************************************


    bitpattern in the source code is 1 and 0 stream
    example of bitpattern = 10011011101110001
    function outbit above has this implement


    ************************************
    void outbit(FILE *fp, int bit)
    {
    fprintf(fp, bit ? "1" : "0");
    }
    ************************************

    I read in MSDN about fprinf

    This is Remarks in MSDN

    "fprintf formats and prints a series of characters and values to the output stream. Each function argument (if any) is converted and output according to the corresponding format specification in format. For fprintf, the format argument has the same syntax and use that it has in printf. "

    I want to ask some question about fprintf function. I think that function write the series of characters to the output stream in the format 0 and 1 but I want to print white and black on the paper (0 = white , 1 = black). I think fprintf only prints a series of characters 0 and 1 to the output stream not print on paper. If you know about how to use that stream to print black and white on the paper please the me and if you can show the example source to do that please show me. Thank you for your answer.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You are not encountering a limitation of 'fprintf'. 'fprintf' can print to a printer. The printer is treated like any other file. What you're having problems with is finding a solid black character. You can use the space for the "white" square. For the black square you'll likely have to use an extended character like: ALT+219 or one of the block shaped extended characters.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CreateThread() function question
    By chiefmonkey in forum C++ Programming
    Replies: 5
    Last Post: 05-15-2009, 08:52 AM
  2. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  3. function pointer question
    By andrea72 in forum C++ Programming
    Replies: 7
    Last Post: 12-11-2007, 06:25 AM
  4. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 11:00 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 10:51 AM

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