【发布时间】:2020-03-06 09:15:58
【问题描述】:
我有以下情况:
数组定义为无符号整数:
uint8 myArray[6][10] = {"continent","country","city","address", "street", "number"};
现在我想获取例如字符串“city”的索引。我想象做这样的事情:
uint8 idx;
for(idx = 0; idx < sizeof(myArray)/sizeof(myArray[0];i++))
{
if((myArray[idx]) == "city") // This can not work because the array is an uint8 array
{
/*idx = 2 ....*/
}
}
不使用 string.h 中的函数(如 strcpy 等)的正确方法是什么...
【问题讨论】:
-
这能回答你的问题吗? How do I properly compare strings?
-
你可以看看这里stackoverflow.com/q/55967430