| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 802 人关注过本帖
标题:还是密码的问题
只看楼主 加入收藏
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
以下是引用amdam23000在2007-5-13 15:24:14的发言:

#include<iostream.h>
#include<conio.h>

void main()
{


char a[23];


cout<<endl;
cout<<"请输入您的密码(6——10位数字或字母):";
int index=0;
while(1)
{
char ch;
ch=getch();

if(ch==8) //退格键
{

if(index!=0)
{
cout<<char(8)<<" "<<char(8);
index--;
}
}
else
{if(ch=='\r') //回车键

{a[index]='\0';
cout<<endl;
break;
}

else
{
cout<<"*";
a[index++]=ch;
}
}
}
}




运行时要enter后才能看见之前输入的密码“*******”;
而且不打印出"请输入您的密码(6——10位数字或字母):"这一行 ;当用stdio.h的printf()时才能打印出来,可密码的问题依旧,
都不知怎么回事了~~~~~~求助~~~~

#include<iostream>
using namespace std; //
#include<conio.h>
void main()
{
char a[23];


cout<<endl;
cout<<"请输入您的密码(6——10位数字或字母):";
int index=0;
while(1)
{
char ch;
ch=getch();

if(ch==8) //退格键
{

if(index!=0)
{
cout<<char(8)<<" "<<char(8);
index--;
}
}
else
{if(ch=='\r') //回车键

{a[index]='\0';
cout<<endl;
break;
}

else
{
cout<<"*";
a[index++]=ch;
}
}
}
}

应该可以实现了吧,下面是图片:

图片附件: 游客没有浏览图片的权限,请 登录注册


Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-05-13 17:25
amdam23000
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2007-5-10
收藏
得分:0 

你的是:

#include<iostream>
using namespace std; //
#include<conio.h>

这样是可以,但我用的是

#include<iostream.h>
#include<conio.h>

这样的话在主函数内怎样才能实现如上的功能?

2007-05-13 17:32
amdam23000
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2007-5-10
收藏
得分:0 

不声明命名空间时怎么办?

2007-05-13 17:36
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
#include<iostream.h>
#include<conio.h>
iostream.h,conio.h;名字空间冲突吧,这个我也不大清楚了,为什么会出现这样的结果。

一般的老的版本的编译器还支持#include<iostream.h>这个形式了,象VC++2005,GCC这样写就会报错
最新标准
#include<iostream>
{
std:cout<<"";
//code here
}
为了不那么多麻烦,大家都愿意这样写
#include<iostream>
using namespace std;

{
//code here
}

Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-05-13 17:53
amdam23000
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2007-5-10
收藏
得分:0 

那好了,谢谢

2007-05-13 21:07
快速回复:还是密码的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018283 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved