扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
1. #include <stdlib.h> 2. #include <stdio.h> 3. #include <windows.h> 4. char buff[1028]; 5. struct user { 6. char *name; 7. size_t len; 8. int uid; 9. }; 10. bool checkpassword() { 11. char password[10]; 12. puts("Enter 8 character password:"); 13. gets(password); 14. if (strcmp(password, "NCC-1701") == 0) { 15. return true; 16. } 17. else { 18. return false; 19. } 20. } 21. int main(int argc, char *argv[]) { 22. struct user *userP = (struct user *)0xcdcdcdcd; 23. size_t userNameLen = 0xdeadbeef; 24. userP = (struct user *)malloc(sizeof(user)); 25. puts("Enter user name:"); 26. gets(buff); 27. if (!checkpassword()) { 28. userNameLen = strlen(buff) + 1; 29. userP->len = userNameLen; 30. userP->name = (char *)malloc(userNameLen); 31. strcpy(userP->name, buff); // log failed login attempt 32. exit(-1); 33. } 34. } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。