滴水逆向指针部分几个实验

#include<stdio.h>
int len(char* s)
{
	int length=0;
	while (*s != 0)
	{
		s++;
		length++;
	}
	return length;
}
char* strcpy(char* dest, char* src)
{
	char* ret = dest;
	while (*src != 0)
	{
		*dest = *src;
		dest++;
		src++;
	}
	return ret;
}
char* strcat(char* dest, char* src)
{
	char* ret = dest;
	while (*dest != 0)
	{
		dest++;
	}
	while (( * dest++ )= ( * src++));
	return ret;
}
bool strcmp(char* dest, char* src)
{
	bool b = true;
	int len1 = 0;
	int len2 = 0;
	char* temp = dest;
	while (*dest != 0)
	{
		dest++;
		len2++;
	}
	dest = temp;
	while (*dest == *src&&*dest!=0)
	{
		dest++;
		src++;
		len1++;
	}
	if (len1 != len2)
	{
		b = false;
	}
	return b;
}
int main()
{
	char x[] = "china";
	char y[] = "xyz";
	printf("%d", strcmp(x, y));
	getchar();
	return 0;
}
#include<stdio.h>
char data[] = {
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,0x74,0x0F,0x41,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
};
void search(int type, int num)
{
	char* pdata = data;
	int length = sizeof(data) / sizeof(data[0]);
	printf("data from:%x", pdata);
	for (int i = 0; i < length - type; i++)
	{
		if (*(int*)(pdata+i) == num)
		{
			printf("address:%x value %d", pdata+i, num);
		}
	}
}
int main()
{
	int type = 4;
	int num = 100;
	search(4, 100);
	return 0;
}
#include<stdio.h>
char data[] =
{
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
};
int len(char* name)
{
	int ret = 0;
	while (*name != 0)
	{
		name++;
		ret++;
	}
	return ret;
}
bool strcmp(char* dest, char* src)
{
	bool ret = true;
	int length = len(dest);
	int length2 = 0;
	while (*dest==*src&&*dest!=0)
	{
		dest++;
		src++;
		length2++;
	}
	if (length != length2)
	{
		ret = false;
	}
	return ret;
}
char* searchName(char* pdata, char* name)
{
	int length = sizeof(data) / sizeof(data[0]);
	int namelen = len(name);
	for (int i = 0; i < length - namelen; i++)
	{
		if (strcmp(name, pdata + i) == 1)
		{
			return pdata + i;
		}
	}
	return 0;
}
void allprint(char* pdata, int type)
{
	int length = sizeof(data) / sizeof(data[0]);
	for (int i = 0; i < length - type; i++)
	{
		for (int j = 0; j < type; j++)
		{
			printf("%c", *(pdata + i + j));
		}
		printf("\n");
	}
}
int main()
{
	char name[] = "WOW";
	printf("address:%x",searchName(data, name));
        allprint(data,4);
	return 0;
}
#include<stdio.h>
typedef struct TagPlayer
{
	int id;
	int level;
}Player;
char a[] = {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x07,0x09,
0x00,0x20,0x10,0x03,0x03,0x0C,0x00,0x00,0x44,0x00,
0x00,0x33,0x01,0x00,0x00,0x08,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x64,0x00,0x00,0x00,0xAA,0x00,
0x00,0x00,0x64,0x01,0x00,0x00,0x00,0x08,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
};
TagPlayer* findtp(char* pa)
{
	int length = sizeof(a);
	TagPlayer* Ptp = (TagPlayer*)a;
	printf("start:%x", Ptp);
	for (int i = 0; i < length - 8; i++)
	{
		if (Ptp->id == 1 && Ptp->level == 8)
		{
			printf("find at:%x", Ptp);
		}
		Ptp=(TagPlayer*)((char*)Ptp+1);
	}
	return 0;
}
int main()
{
	findtp(a);
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

努力不当无业游民

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值