Reading in text file into an array, white spaces...
I'm obviously a newbie with this whole programming thing (hence my name "error," perhaps should be "errors" lol), so I have a simple question. It is my understanding that when you want to read data into an array from a text file there has to be white space between each character, is there a way to get around this and if so how? You cannot fill an index with a white space can you?
I want to be able to access each character from a series of sentences individually, that is make it so each character from that sentence is in its own index in an array. I don't want to have to put white space between each character in the sentences you know.
Re: Reading in text file into an array, white spaces...
Quote:
Originally posted by error
I'm obviously a newbie with this whole programming thing (hence my name "error," perhaps should be "errors" lol), so I have a simple question. It is my understanding that when you want to read data into an array from a text file there has to be white space between each character, is there a way to get around this and if so how? You cannot fill an index with a white space can you?
I want to be able to access each character from a series of sentences individually, that is make it so each character from that sentence is in its own index in an array. I don't want to have to put white space between each character in the sentences you know.
OK, rewind just a bit here.
1) A character is just a single byte, and is an actual numerical value.
2) The whitespace is a "character" too, which has a value of 32 in decimal, 0x20 in hexidecimal.
3) Spaces are not placed between characters in files unless you put them there.
4) Likewise for arrays.
It is the word processor that converts each byte into a visible char. Otherwise, they are simply numbers.
A file is itself an array, and you can read the contents directly into an array. There will not be any extra whitespace, and each index into that array (start at zero, of course), will be the corresponding character...