Hi,
I am having an issue with reading a single byte from a file.
I want to read a byte from a file and set a NumericUpDown controls' value to the byte that was read from the file. Below is the code I have.
Thanks.
I have a horizontal control that sets the value of the NumericUpDown1 control. This value is written to the file.
It works from 0 to ~100 or so but anything higher I don't get the correct number in NumericUpDwon1 control. When setting the Horizontal control to 255 I get a -1 value when I read it from the file.
Line 6 is assigning the 2nd element of a 1 char array to the control. You are assigning a value not read from the file, going out of bounds of the array, retrieving whatever bogus value at a memory location outside of the array.
Remember, in C/C++ an array's first element is looked up with operator[0], as JLBorges shows.