Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

how to print bold and underline text with c++

grahamojgrahamoj Posts: 366Member
Hiya, how can I cout bold and underline text in c++??
Is there functions to do this??

thanks,
grahamoj.

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    : Hiya, how can I cout bold and underline text in c++??
    : Is there functions to do this??
    :
    : thanks,
    : grahamoj.
    :

    print it where? on a lazer printer, a dos window, unix command line, windows window ? Please be more specific.
  • grahamojgrahamoj Posts: 366Member
    : : Hiya, how can I cout bold and underline text in c++??
    : : Is there functions to do this??
    : :
    : : thanks,
    : : grahamoj.
    : :
    :
    : print it where? on a lazer printer, a dos window, unix command line, windows window ? Please be more specific.
    :
    I want to print it out on a laser printer. I am using Visual C++ 6.0 and a console app with fprintf.

    thanks,
    grahamoj.
  • stoberstober Posts: 9,765Member ✭✭✭
    You need to read your printer's owener manual and programmer's manual. There is not standard way of going things like that, and that's why there are so many printer drivers for your computer. Every printer is a little different. The printers I've used, I had to send a sequence of characters to start the underline and another sequence of characters to stop it. I don't recall what those characters are, but it doesn't matter because your printer will be different anyway.
  • grahamojgrahamoj Posts: 366Member
    : You need to read your printer's owener manual and programmer's manual. There is not standard way of going things like that, and that's why there are so many printer drivers for your computer. Every printer is a little different. The printers I've used, I had to send a sequence of characters to start the underline and another sequence of characters to stop it. I don't recall what those characters are, but it doesn't matter because your printer will be different anyway.
    :
    Thanks for that but I think you are missing the point of what I mean. I know I could print text out in bold using the printer settings but I thought I could send the text to the printer in bold or underline using my code .e.g fprintf( "My Heading",BOLD ); // or something like that

    If this is not possible, how do I print bold and underline text on a console window??

    Thanks for your help.
    grahamoj.
  • AndreaFAndreaF Posts: 88Member
    : : You need to read your printer's owener manual and programmer's
    ...
    : Thanks for that but I think you are missing the point of what I mean. I know I could print text out in bold using the printer settings but I thought I could send the text to the printer in bold or underline using my code .e.g fprintf( "My Heading",BOLD ); // or something like that

    You are missing the point.
    If you want to directly access a laser printer, you need to look to the printer docs.
    If you want to access a system printer under windows, go throu the windows APIs (printing is done much like drawing in a graphical window).

    Now you say you want to print to a console screen. There are some (somewhat limited) possibilities to access the console window. Look for the console APIs in a Win32 reference.

    What you want to do (changing output color with printf) cannot be done. And the reason is very simple: printf writes to stdout. Ans stdout is a virtual text file. Even if it's virtual it still is a text file. And "writing bold and underlined text to a text file" is a nonsense. A text file just contains text, not color or font.

    The fact that you are running your program in a modality that takes your stdout virtual file and prints it to a console is incidental. It does not have to be so.

    -AF

  • ArielRArielR Posts: 5Member
    I am using this code to print in a dot printer.... may be it serve to you.

    //to configure the page.
    int iEsc= 27; //
    int iAlto1= 67; //
    int iAlto2= 72; //
    int iSalto= 12; // jump to the end of page.

    int iCondesado = 15; //condensed
    int iNormal = 18; //normal
    int iDoble = 14; //double high
    int iCanDbl = 20; //cancel double high

    and

    stream = fopen( "LPT1", "w" );

    int iPos = fprintf( stream, "%c%c%c", iEsc,iAlto1, iAlto2);

    and I need your help... How did you check if LPT1 is ready to write?, thank



Sign In or Register to comment.