使用visual c ++ 6.0时要使用的代码

时间:2011-01-30 17:40:54

标签: c vc6

我在borland c ++编译器中编译并执行了以下c代码。它完美地工作但它在visual c ++ 6.0编译器中不起作用。要使它在visual c ++ 6.0中运行会有什么变化?

#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>

int main()
{
    char buffer[256] = {0};
    char password[] = "password";
    char c;
    int pos = 0;

    printf("%s", "Enter password: ");
    do {
        c = getch();

          if( isprint(c) )
        {
            buffer[ pos++ ] = c;
            printf("%c", '*');
        }
        else if( c == 8 && pos )
          {
            buffer[ --pos ] = '\0';
            printf("%s", "\b \b");
        }
     } while( c != 13&& pos < 256 );

    if( !strcmp(buffer, password) )
        printf("\n%s\n", "Logged on succesfully!");
    else
        printf("\n%s\n", "Incorrect login!");

    return 0;
}

1 个答案:

答案 0 :(得分:0)

vc 6,不支持conio。 删除包含。

getch不会做你期望它做的事。

考虑在vc6下构建console app