C语言,字符串处理函数

辅助函数1
|
C语言在线编译器1

1、字符串分割:

#define SubRows (10)
#define SubCols (20)
uint8_t strSublists[SubRows][SubCols];
void strSplit(const uint8_t* strSrouse);

void strSplit(const uint8_t* strSrouse)
{
	uint8_t i = 0;
	MC20_ClearSublists();

	uint8_t delims[] = ",";//以','分割
	uint8_t* result = NULL;
	result = strtok(strSrouse, delims );
	while( result != NULL ) {
		CopyAtoBAll(result, strSublists[i++]);
		result = strtok( NULL, delims );
	}
}

void main(){
	uint8_t * strTest = "0,42,3725";
	strSplit(strTest);
	for(uint8_t i = 0; i < 3; i++){
		print("%s\n", strSublists[i]);
	}
}


[]:
[]:
[]:

发布了85 篇原创文章 · 获赞 27 · 访问量 16万+

猜你喜欢

转载自blog.csdn.net/qq_22038327/article/details/99120856