[英]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.