注册 登录
编程论坛 C++教室

[求助]一个小问题

tyb103 发布于 2007-01-11 15:56, 512 次点击
本人学的c++ 一个学期了
这期末项目里有个问题不知道 想请教请教
期末项目是写个图书管理系统, 要在里面实现管理员功能问题就在这了
当输入管理员账号后 再输入密码是怎样才能实现输入一个数后显示的是 “*
本人刚学 什么都不懂 但很努力的
请指教
先谢谢了
5 回复
#2
tyb1032007-01-12 18:41
郁闷啊
怎么没人回啊
#3
yuyunliuhen2007-01-12 22:45
有个相关的程序,可以参考一下



#include "stdio.h"
#include "conio.h"
#include <iostream>
#include <string>
#include "stdio.h"
using namespace std;
char password[9]="00000000"; //8 num of password
char temp;
int index=0;
void main()
{
while( temp=getch() )
{
if(temp==0x08&&index>0) /* 如果是后退 */
{
putch(temp);
putch(' ');
putch(temp);
index--;
}
else if(temp==0xd)
{
if(index==8) /* 输入了八个字符比较 */
{

if(strcmp(password,"20021112")==0)
{
printf("\n 密码正确 \n",password);
break;
}
else
{
fflush(stdin); /*输出字符不够或多了*/
index=0;
printf("\npassword is wrong please input again\n");
}
}
else
{
fflush(stdin); /*输出字符不够或多了*/
index=0;
printf("\npassword is shortor long please input again\n");
}
}
else
{
if(index<9)
{
password[index]=temp;
index++;
}
printf("*");
}
}
}
#4
tyb1032007-01-13 21:24
我是刚学的
好多看不懂
郁闷
还要努力

我只学了C++
前面地路还很远
要学的好很多

还是要谢谢斑竹
#5
一二三四五2007-01-13 21:59
我觉得还是从最基础的东西开始学好
学程序可不能急的哦
#6
tyb1032007-01-14 17:24

谢谢斑竹
指教
斑竹
1