triangle/arduino/problems and reasons.txt

11 lines
633 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

问题1wifi接受到的数据为const uint_8 不能直接用atoi转换为int。
解决atoi((char*)(packet.data())) //使用(char*) 进行强制类型转换
问题2c语言中sizeof()返回的是变量声明后所占的内存数不是实际长度。strlen是一个函数求的是字符串的实际长度它求得方法是从开始到遇到第一个'\0',如果你只定义没有给它赋初值这个结果是不定的它会从arr首地址一直找下去直到遇到'\0'停止
解决字符串转换中使用strlen()获得实际长度
问题3数字转字符串中可以使用sprintf
解决sprintf(s, "%d", 100//将100转为10进制表示的字符串
问题4强制类型转换(const unsigned char*)不能直接使用print输出
解决atoi((char*)(packet.data())) //使用(char*) 进行强制类型转换