Print Variables
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Print Variables

  1. #1
    Join Date
    Oct 2003
    Location
    KY USA
    Posts
    44

    Print Variables

    Hey all,

    As stated before, I'm new to MFC programming. I come from the old DOS days. MS Quick C.

    So here is my problem. During programming, I usually will put a few print statements in the code to monitor varibles or to mark that a function has been reached. Used to be I just used printf or the old _outtext(array,"CCC"var);

    Well -outtext isn't in the lib and printf will not put anything to screen. Unless it's writing in the same color as my background.

    So in short, I need to know how to quickly print a literal string/char or varible to screen.

    Thanks. And yes I did look on the Code Guru pages/f.a.q. but couldn't find anything that would help.

    Again, Thanks in advance for any and all responses

    Jerry

  2. #2
    Join Date
    Nov 2003
    Location
    Beijing, China
    Posts
    5
    Maybe you can using std::cout, which prints the variables' value to screen. For most funtamental types, std defined the operator <<, which performs output operation. For a customized type, you should also define the operator <<.

  3. #3
    Join Date
    Oct 2003
    Location
    KY USA
    Posts
    44
    Thanks Icy,

    I tried the cout<< but it wouln't print to screen. I had also tried printf. Same result. I believe the issue is I am writing an MFC window and not a console app. I could be wrong though.

    I ended up using TextOut as such...

    void C_MainFrame::OnStart()
    {

    CClientDC StartDC(this);

    if(C_MainFrame::C_Status == 'J')
    C_MainFrame::C_Status = 'G' ;

    if(C_MainFrame::P_Status == 'J')
    C_MainFrame::P_Status = 'H' ;

    StartDC.TextOut(10,10, C_MainFrame::C_Status);
    StartDC.TextOut(30,10, C_MainFrame::P_Status);


    }

    Probably not the best way but it worked and now I can delete it and continue on with the program

    Thanks again.
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center