#include <conio.h>
#include <windows.h>
#include <stdio.h>
int main ()
{
char input[255];
int i = 0;
for(;;i++) /* Infinite loop, exited when RETURN is pressed */
{
char temp;
temp = getch (); /* Get the current character of the password */
if (GetAsyncKeyState (VK_RETURN)) /* If the user has pressed return */
{
input[i]='\0';
break;
}
input[i] = temp;
printf("*"); /* Print a star */
}
//printf("%s",input);
if(strcmp(input,"kamal")==0)
{
printf("ACCEPTED");
}
else
printf("not");
_getch();
return EXIT_SUCCESS; /* Program was executed successfully */
}
这是我的代码。我怎样才能防止缓冲区溢出,如果我输入密码更多,那么我的程序就会崩溃。无论如何我可以克服这个问题吗?