我从服务器获取URL输入如下:
http://10.0.0.70/distance=150/angle=60
现在如何从此URL获取距离和角度参数并将其存储到另一个变量中?
我必须在Arduino编程语言中使用它。
答案 0 :(得分:1)
这应该有效
char str[] = "http://10.0.0.70/distance=150/angle=60";
char * pch;
char *ptr;
long ret;
pch = strchr(str,'='); // find '='
ret = strtoul(pch, &ptr, 10); // take the number after it (here ret = 150)
pch = strchr(pch+1,'='); // find the next '='
ret = strtoul(pch, &ptr, 10); // take the number after it (here ret = 60)