[英]password program not working in c++
密码程序不起作用...我正在与dev c ++一起使用,并且它可以识别conio.h ...请帮助...我应该怎么做?也许我还有另一个错误...请说要更正它。tnx
#include<string.h>
#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
void main()
{
char pass[5];
int o;
string password= "password";//this is the password
for(int i=0;i<5 ;i++)
{
pass[i]=_getch();
_putch('*');
}
string a(pass);
if(a==password)
{cout<<"correct"<<endl;}
else
{cout<<"wrong"<<endl;}
}
因为conio.h不是C标准的一部分。 它是Borland的扩展,仅与Borland编译器(也许还有其他一些商业编译器)一起使用。 Dev-C ++使用GCC(GNU编译器集合)作为其编译器。 GCC最初是UNIX编译器,旨在实现可移植性和符合标准。
如果真的不能没有它们,可以通过以下方式使用Borland函数:将conio.h包含到源代码中,并将C:\\ Dev-C ++ \\ Lib \\ conio.o添加到“项目选项”中的“链接器选项”(其中C :\\ Dev-C ++是安装Dev-C ++的位置)。 请注意,conio支持远非完美。
AJ是正确的,但请注意其他系统(例如Linux,Win32和OS / 2)提供了这些功能的不同实现。
在Linux系统上, #include <curses.h>
将为您提供conio.h提供的几乎所有功能。
对于getch()和朋友,您的第一站可能在那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.