标题:萌新上路,代码写的很恶心,可读性差,大佬勿喷
取消只看楼主
鱼头豆腐汤
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2020-10-21
结帖率:100%
 问题点数:0 回复次数:2 
萌新上路,代码写的很恶心,可读性差,大佬勿喷
#include "stdafx.h"

char x[]=
{
    0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x07,0x09,                    
    0x00,0x20,0x10,0x03,0x03,0x0C,0x00,0x00,0x44,0x00,                    
    0x00,0x33,0x00,0x47,0x0C,0x0E,0x00,0x0D,0x00,0x11,                    
    0x00,0x00,0x00,0x02,0x64,0x00,0x00,0x00,0xAA,0x00,                    
    0x00,0x00,0x64,0x10,0x00,0x00,0x00,0x00,0x00,0x00,                    
    0x00,0x00,0x02,0x00,0x74,0x0F,0x41,0x00,0x00,0x00,                    
    0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0A,0x00,                    
    0x00,0x02,0x57,0x4F,0x57,0x00,0x06,0x08,0x00,0x00,                    
    0x00,0x00,0x00,0x64,0x00,0x0F,0x00,0x00,0x0D,0x00,                    
    0x00,0x00,0x23,0x00,0x00,0x64,0x00,0x00,0x64,0x00                    
};

char y[]={"WOW"};
int l=0;
char* FindRoleNameAddr(char* x,char* y)   
{
    int n;
    char* e;
    char* a=&y[0];
    char* b=&x[0];
    for(int i=0;i<100;i++)
    {
        n=0;
        y=a;
        x=b++;
        e=x;
        while(*y!=0)
        {
            if(*y==*x)
            {
                n++;
                x++;
                y++;
            }else
            {
            break;
            }
        }
        if(n==3)
        {
            l++;
            return e;
        }
    }
    return 0;
}               

int main()
{
    int* t=(int*)FindRoleNameAddr(x,y);
    printf("%x\n",t);
    char* f=FindRoleNameAddr(x,y);
    while(*f!=0)
    {
        printf("%c",*f);
        f++;
    }
    printf("\n%d",l);
    return 0;
}
搜索更多相关主题的帖子: 可读性 printf return char int 
2022-11-18 22:40
鱼头豆腐汤
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2020-10-21
得分:0 
回复 2楼 apull
int len = sizeof(x) / sizeof(x[0]);

while(a-x<len-2)
这两句不是太懂,可以麻烦大佬讲一下吗?
2022-11-19 00:14
鱼头豆腐汤
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2020-10-21
得分:0 
回复 4楼 apull
明白了,谢谢大佬
2022-11-19 09:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-510698-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013679 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved