改变输出方式,cmd下不断的输出问题

guxue365 2009-01-19 12:01:16
为什么我把这一贴上的程序http://topic.csdn.net/u/20090112/22/4b7bfde1-1d37-4b7a-8dfe-ecb3ddd715a9.html改成如下就就使得控制台不断的输出呢

#include <iostream>
#include <windows.h>
using namespace std;

int main(void)
{
while (1)
{
POINT pos;
GetCursorPos(&pos);
cout<<pos.x<<";"<<pos.y<<endl;
Sleep(10);
}


return 0;
}
原来的源代码是这样的:
#include <iostream>
#include <windows.h>
using namespace std;

int main(void)
{
while (1)
{
POINT pos;
GetCursorPos(&pos);
printf("%d,%d \r", pos.x, pos.y);
Sleep(10);
}

return 0;
}

...全文
134 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
nullah 2009-01-19
  • 打赏
  • 举报
回复

#include <iostream>
#include <windows.h>
using namespace std;

int main(void)
{
while (1)
{
POINT pos;
GetCursorPos(&pos);
cout << pos.x << ";" << pos.y << "\r";//------------------------>here
Sleep(10);
}


return 0;
}

jack_za123 2009-01-19
  • 打赏
  • 举报
回复
我理解错了


#include <iostream>
#include <stdio.h>//你少了这个包
#include <windows.h>
using namespace std;

int main(void)
{
while (1)
{
POINT pos;
GetCursorPos(&pos);
printf("%d,%d \r", pos.x, pos.y);
Sleep(10);
}

return 0;
}
vanta 2009-01-19
  • 打赏
  • 举报
回复
while (1)什么时候能跳出来呢?
tangshuiling 2009-01-19
  • 打赏
  • 举报
回复
不知道楼主问什么?是while(1)? 还是?
jack_za123 2009-01-19
  • 打赏
  • 举报
回复
你一直处于while循环里啊 所以会一直输出啊
yangkunhenry 2009-01-19
  • 打赏
  • 举报
回复
<<endl
去掉

64,683

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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