我有 C 代码,我正在尝试将此代码与 arduino ide 一起使用。我正在尝试转换此函数,但无法使用 arduino ide 在转换后的函数中打印任何内容。
这是c中的原始代码
int num_alphabets = 256;
int num_active = 0;
int *frequency = NULL;
unsigned int original_size = 0;
void fre(File &f) {
int c;
while ((c = fgetc(f)) != EOF) {
++frequency[c];
++original_size;
}
for (c = 0; c < num_alphabets; ++c)
if (frequency[c] > 0)
++num_active;
}
这是新功能:
void fre(File &f) {
while ((c = f.read()) != -1){
char nextChar = (char) c;
Serial.printf("---------- c = %d \n",c); // there is no thing printed here
if (nextChar != '\n')
{
++frequency[c];
++original_size;
}
}
for (c = 0; c < num_alphabets; ++c){
if (frequency[c] > 0)
++num_active;}
}