这似乎是一个基本问题,但我在 SO 的任何地方都找不到答案。
我知道 C/C++ 没有byte
数据类型。我知道sizeof(char) == 1
。
我试图在 Pebble 上存储 12 个传输,每个 96 个字节,从我的 Android 应用程序传输。
由于传输大小的限制,我一次发送一个。每个都应该“附加”到最后一个,因为它们最终应该在内存中形成顺序空间,以作为图像读取(每像素一位)。
我正在尝试做这样的事情:
int transNum = 0;
uint8_t image[][] = new uint8t[12][12] //not sure about uint8_t, and I've forgotten how to do 'new' in C, I have to create just a pointer, and then malloc?
receivedHandler(DictionaryIterator *iter, void *context){
Tuple *receivedImage = dict_find(iter, KEY_IMG);
for (int i = 0; i < 12; i++) {
image[transNum][i] = receivedImage->value[i]->uint8_t;
}
transNum += 1; //this is in an implicit loop, since once done Pebble ACKs the transmission, and receivedHandler is called again by the next transmission
}
我什至离得很近吗?