我正在尝试从一周中的某一天获取单个字符。这就是我所拥有的。
const char *daysOfTheWeek[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
const char *tc = daysOfTheWeek[dayOfWeek];
text_layer_set_text(&dow_one, &tc[0]);
text_layer_set_text(&dow_two, &tc[1]);
text_layer_set_text(&dow_three, &tc[2]);
出现的是
&dow_one = ...
&dow_two = ed
&dow_three = d
我想要的是
&dow_one = W
&dow_two = e
&dow_three = d
如果我删除 & 并只使用 tc[0] 我会得到一个编译错误。
83:9:错误:传递 'text_layer_set_text' 的参数 2 使指针从整数而不进行强制转换 [-Werror] /Users/myke/pebble_dev/pebble-sdk-release-001/watches/iWatch/include/pebble_os.h:677 :6: 注意:预期为 'const char *' 但参数是 'char' 类型
这是一个无法访问 sprintf 的嵌入式系统。仅纯 C