04-10-2025 10:32 AM
Good morning,
I have this code, but every 256 numbers the buffer is empty, so when it's written to memory, it's zero.
The remaining numbers do contain information.
What could be happening and how can I resolve the buffer not being emptied?
****************************************************
int main(int argc, char *argv[])
{
unsigned int ui;
unsigned char buf[256];
ui = (unsigned int) atoi ("80640");
buf[0] = ( (ui ) & 0xFF);
buf[1] = ( (ui >> 😎 & 0xFF);
buf[2] = ( (ui >> 16) & 0xFF);
buf[3] = ( (ui >> 24) & 0xFF);
****************************************************
Results in Number is 80640
buf[0] = ""
buf[1] = ""
buf[2] = ""
buf[3] = ""
Results in Number is 80641
buf[0] = "\1\5"
buf[1] = "\1;"
buf[2] = "\1;\1u\330Yp"
buf[3] = "\1;\1"
04-15-2025 03:28 AM
Hello VicTowers,
If I understand correctly, there's some more code missing here (such as print functions). At a first glance, I think there might be string and integer mismatching happening. I'm not yet proficient in C#, can you please verify if the mismatching is the issue? I think someone else may be more helpful if more context is added.
04-16-2025 07:06 AM - edited 04-16-2025 07:08 AM
Hello Vic
In the debugger set break point after the assignment to buff[0..3] and view the buf variable in HEX bytes mode
CVI assumes that buf[256] is a string so the firs "char" buf[0] is 0x00 -> NULL in the case of "80640" than you can not see the rest 3 bytes