Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot use printf, sprintf and cout in MFC (exe) window 1

Status
Not open for further replies.

gearbox88

Technical User
Dec 28, 2003
1
US
Hello guys, I've been experimenting with a PCI data aquisition card in my home computer that is running on WIN 98. I am using Visual C++ 5 to build an Win32 MFC (exe)application program to display the 8 bits data retrived by the card, thats when I run into a problem of displaying the data. I've tired printf, sprintf, cout and std::cout with no output on the window. I've already loaded all the header file necessary - #include "iostream.h"
#include <iostream>
#include &quot;stdio.h&quot;
#include &quot;conio.h&quot;
#include &quot;stdlib.h&quot;
The program compiled and linked without any errors but there is no output in the window even when I tried a simple string output like &quot;hello&quot;.
The only function that could output characters in the window is the device context &quot;TextOut&quot;, but it only outputs ascii text and not the decimal equivalent that I want it.

So can someone out there help me out please. Thanks.

 

You can use sprinf() to format the string but if you are already in MFC then you can use CString.Format and BOOL TextOut( int x, int y, const CString& str );
Example:
CDC myCDC;
CString sTemp;
int nRead = 2048;
int l=1;
int c = 1;
sTemp.Format(&quot; Reading data from : %s, Number of bytes = %d &quot;, &quot;COM1:&quot;, nRead);
myCDC.TextOut(l, c, sTemp);
sTemp.Format(&quot;End receiving data from : %s, Total bytes read = %d&quot;, &quot;COM1:&quot;, nTotal);
myCDC.TextOut(l+1, c+1, sTemp);
//...

2. Depending on what is your GUI for this application you could use other possibilities that ofer MFC.
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top