本文共 1405 字,大约阅读时间需要 4 分钟。
大家都知道scanf()遇到空格后就会结束 原因是底层函数是这么返回给你的
调用scanf()时 那现在从底层把他截获源码://vs2015#include为什么打那么多呢 其时底层不管你打什么它都保存在那 用途:优化下可以作为登录密码(我本来就是逆出来的)#include using namespace std;_ACRTIMP_ALT FILE* __cdecl __acrt_iob_func(unsigned);#ifdef __cplusplus extern "C"#endif FILE* __cdecl __iob_func(unsigned i) { return __acrt_iob_func(i);}// 全局变量char g_szId[120] = { " i love this game\n\n" };#pragma comment(lib,"user32.lib")int main(){ // 局部变量 char szBuf[120]; printf("please input password: "); scanf_s("%s", szBuf, 120); char* p = *(char**)((int)__iob_func(0) + 4); //取缓冲区中的值 __iob_func(0)输入 //__iob_func(1)输出 __iob_func(2)错误 printf("%s\n", szBuf); printf("%s", p); if (strcmp(p, g_szId) == 0) { printf("It's Right\n"); } else { printf("It's Err \n"); } system("pause"); return 0;}//vc6.0版 //#include "stdio.h"//#include 全局变量//char g_szId[120] = { " i love this game\n\n" };//#pragma comment(lib,"user32.lib")////int _tmain(int argc, _TCHAR* argv[])//{// // 局部变量// char szBuf[120];// printf("please input password: ");// scanf_s("%s", szBuf, 120);//// char* p = *(char**)((int)__iob_func() + 8);// if (strcmp(p, g_szId) == 0)// {// printf("It's Right \n");// }// else// {// printf("It's Err \n");// }// system("pause");//// return 0;//}
转载于:https://blog.51cto.com/haidragon/2118179