鱼C论坛

 找回密码
 立即注册
查看: 2476|回复: 2

求助各位鱼油

[复制链接]
发表于 2017-4-29 17:39:12 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 drt 于 2017-4-30 11:24 编辑

#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <conio.h>
using namespace std;
string number1;
string number2;
string name;
void Gotoxy(int x, int y) //光标函数
{
    int xx=0x0b;
    HANDLE hOutput;
    COORD loc;
    loc.X = x;
    loc.Y = y;
    hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(hOutput, loc);
    return;
}
int in()
{
    number2.clear();
    system("cls");
    cout<<"                         =========================="<<endl;
    cout<<"                         #    请输入账号          #"<<endl;
    cout<<"                         =========================="<<endl;
    cout<<"                         #                        #"<<endl;
    cout<<"                         =========================="<<endl;
    cout<<"                         #    请输入密码          #"<<endl;
    cout<<"                         =========================="<<endl;
    cout<<"                         #                        #"<<endl;
    cout<<"                         =========================="<<endl;
    Gotoxy(30,3);
    getline(cin,number1);
    //cin.ignore(100,'\n');
    Gotoxy(30,7);
    char ch;
    int count = 0;
    while(ch = getch())
    {
        if(ch == '\r')
        {
            break;
        }
        if(ch == 8)
        {
            if(count != 0)
            {
                cout<<char(8)<<" "<<char(8);
                number2.erase(number2.size()-1,1);
                count--;
            }
        }
        else
        {
            if(count < 20)
            {
                count++;
                cout<<"*";
            }
            number2.push_back(ch);
        }

    }
    if(GetAsyncKeyState(VK_DELETE))
    {
        return 0;
    }

}

int main()
{
    in();
    cout<<"nsjwhfchewhie";
}

请问为什么这个异步按delete键不能结束函数啊
求助 谢谢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-4-29 18:12:38 | 显示全部楼层
把代码贴完整
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-4-29 21:16:40 | 显示全部楼层
本帖最后由 drt 于 2017-4-30 11:25 编辑


好的好的  不好意思啊 谢谢你了   已经补全完毕了   就是这个我想就是  按下delete键就可以结束in函数然后打印最后面的乱码  不知道为什么没有用  谢谢你了  求帮忙看看
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-28 06:20

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表