简单问题:printf函数输出到哪里去了?

Jover 2003-01-06 10:14:35
我怎么看不到结果。
...全文
1145 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
叶子哟 2003-01-06
  • 打赏
  • 举报
回复
看你的功能需求:printf或是sprintf或是其它都有它的应用范围
Jover 2003-01-06
  • 打赏
  • 举报
回复
能详细说明一下吗?
kingfish 2003-01-06
  • 打赏
  • 举报
回复
console winzard下可以

sprintf是输出到stdout的,对Application当然不行了

就用别的吧,比如
Label->Caption=
ShowMessage();
...
Jover 2003-01-06
  • 打赏
  • 举报
回复
加分了!
Jover 2003-01-06
  • 打赏
  • 举报
回复
BCB里有没有像VB里的DEBUG.PRINT的功能?
cupidvenus 2003-01-06
  • 打赏
  • 举报
回复
Application不用printf函数,改为控制台程序吧!
favorit 2003-01-06
  • 打赏
  • 举报
回复
String str;
int i=5;
Edit1->Text = str.sprintf("this is %d",i);
Jover 2003-01-06
  • 打赏
  • 举报
回复
BCB人气好低:(
Jover 2003-01-06
  • 打赏
  • 举报
回复
是APPLICATION。
favorit 2003-01-06
  • 打赏
  • 举报
回复
是控制台程序吗?如果是的话,return前面加一句getch();
否则屏幕会一闪而过
TopCat 2003-01-06
  • 打赏
  • 举报
回复
我写了一个Debug类,应该能达到你的效果。用法很简单,包含头文件后,在需要的地方使用:Debug.Print(<参数>)即可,参数用法跟printf相同。

debug.h:
-------------------
//---------------------------------------------------------------------------
#ifndef debugH
#define debugH

#include <windows.h>
#include <stdarg.h>
//---------------------------------------------------------------------------
class CDebug
{
public:
inline ~CDebug();

void Print(const char *prompt, ...);
static CDebug &GetInstance();
private:
static CDebug s_debug;
HANDLE m_StdOut;

inline CDebug();
};

extern CDebug Debug;
#endif
-----------------------------------

debug.cpp:
----------------------
//---------------------------------------------------------------------------

#include <stdio.h>
#pragma hdrstop

#include "debug.h"

//---------------------------------------------------------------------------
CDebug CDebug::s_debug;

CDebug Debug = CDebug::GetInstance();

inline CDebug::CDebug()
{
AllocConsole();
m_StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
}

inline CDebug::~CDebug()
{
FreeConsole();
}

inline CDebug &CDebug::GetInstance()
{
return s_debug;
}

void CDebug::Print(const char *prompt, ...)
{
DWORD w;
char * buf = NULL;
int size = 0;
int i = 0;
va_list args;
int rc;

va_start (args, prompt);

do {
size += 1000;
if (buf)
{
delete[] buf;
buf = NULL;
}
buf = new char[size];
i = vsnprintf (buf, size, prompt, args);
} while (i == size);

va_end(args);

WriteFile(m_StdOut, buf, strlen(buf), &w, NULL);

if (buf)
{
delete[] buf;
buf = NULL;
}
}

#pragma package(smart_init)
------------------------------------
kylixcq 2003-01-06
  • 打赏
  • 举报
回复
Form1->Canvas->TextOutA(int x,int y,Ansistring ouputtext)
Jover 2003-01-06
  • 打赏
  • 举报
回复
能不能不用控件,
就像VB一样打印到立即窗口,
调试的时候可以看见,
变成可执行文件就无效。
kingfish 2003-01-06
  • 打赏
  • 举报
回复
Memo1->Lines->Add(s1);
Jover 2003-01-06
  • 打赏
  • 举报
回复
不是,要监视一些中间过程,只看结果我知道该怎么做。
yuliwe 2003-01-06
  • 打赏
  • 举报
回复
你只想看到结果么?如果是这样,可以使用一个控件,将结果打到控件里去显示就好了
Jover 2003-01-06
  • 打赏
  • 举报
回复
我想在appliaction运行过程中,
显示一些状态出来。

13,826

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧