2

Password program not working...im working with dev c++ and it dosent recognize conio.h...please help...what shoud i do??maybe i have another errors...please say to correct it.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;}
}
Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85
  • This program is a horrific mix of C and C++ for a heavily outdated compiler. I implore you to pick up a [decent, up-to-date book on C++](http://stackoverflow.com/q/388242) and learn from that. – The Forest And The Trees Oct 18 '13 at 07:46

2 Answers2

1

Because conio.h is not part of the C standard. It is a Borland extension, and works only with Borland compilers (and perhaps some other commercial compilers). Dev-C++ uses GCC, the GNU Compiler Collection, as it's compiler. GCC is originally a UNIX compiler, and aims for portability and standards-compliance.

If really can't live without them, you can use Borland functions this way: Include conio.h to your source, and add C:\Dev-C++\Lib\conio.o to "Linker Options" in Project Options (where C:\Dev-C++ is where you installed Dev-C++). Please note that conio support is far from perfect.

AJ.
  • 4,526
  • 5
  • 29
  • 41
0

AJ is correct but note that other systems such as Linux, Win32 and OS/2, provide different implementations of these functions.

On a linux system the #include <curses.h> will give you almost all the functionality that was provided by conio.h

For getch() and friends, your first stop might be there.

Montdidier
  • 1,181
  • 1
  • 8
  • 21