仿strstr()搜索指定子數組

仿strstr()搜索指定子數組

uint8_t* memstr(const uint8_t * buf1, const uint8_t * buf2,unsigned int buf1len, unsigned int count) {
	unsigned int i = 0;
	for (i = 0; i < buf1len- count; i++) {
		if (memcmp(buf1+i, buf2, count) == 0) {
			return (uint8_t*)(buf1 + i);
		}
	}
	return NULL;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章