c# - Reading numbers from a text file to an array -


i want read numbers text file array. numbers in 1 line.

  • if use x.read() ascii code of first character,

  • if use x.readline(), row, not numbers 1 one.

i want use cycle numbers 1 one.

it's simple, when ascii code can convert digit want, suppose read character (char ) file '0', '1', '2', ... or '9' , want int value, simple convert char int , subtract integer value of '0' 48. this:

char ch = x.read(); int chintvalue = ((int)ch) - 48; 

but modern programming languages have readint, getinteger method or in io libraries provide.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -