char* askForAString(void)
{
char temp[16] = ""; //这里是第81行
//scanf("%s", temp);
//fflush(stdin);
return temp;
}
char password[16] = "evlos";
char inputpsw[16];
inputpsw = askForAString(); //这里是第100行
if (strcmp(password, inputpsw) == 0)
{
printf("Allowed!");
}
projectv0.cpp: In function ‘char* askForAString()’:
projectv0.cpp:81: warning: address of local variable ‘temp’ returned
projectv0.cpp:100: error: incompatible types in assignment of ‘char*’ to ‘char [16]’
请问如何修改才能让程序正常运行?
再请问 “warning: address of local variable ‘temp’ returned” 这个错误是怎么产生应该如何避免呢?
谢谢啦 =w=