Kjeldgaard
- Joined Apr 7, 2016
- 476
@djsfantasi I have tried to develop a Stand Alone Programmer project with a C program for a PIC and a Windows Control program in Object Pascal.
A char array is not a string unless it is terminated by null (the zero byte). Without the null, string library functions won't be able to know when the string ends. When you are constructing your own char arrays, it is up to you to ensure that the array is null terminated. Some string library functions will take care of this for you, others won't.But is still not fully clear to me how do I detect and handle null character.
If you read the man page for the strncpy function, you'll see that it does not assure the destination buffer is null terminated. What you are doing is asking strncpy to copy 13 bytes to the 256-byte list_of_networks[j] buffer. But the string you are copying is 14 bytes long: 13 characters + null termination. So, you need to either terminate the buffer yourself: list_of_networks[j][13] = 0. Or, tell strncpy to copy length() + 1 bytes.C:strncpy(list_of_networks[i],temp_buffer,WiFi.SSID(i).length());