Now, I'm collecting characters from a file one at a time like this:
1 2 3 4 5 6 7
while(!sin.eof()){
char * oneChar;
oneChar = newchar [1]; // not sure what 1 means here, but it's been working
sin.read(oneChar,1);
cout.write(oneChar,1); // Correct char
}
I get the right char from my file but now I want to insert that char into my array of type myType. How can I convert the char into a myType so that I can place it into my array??
I'd like to make one remark on your showed code
You should delete memory allocated in the loop. Otherwise you have a memory leak. So it would be correct to write
1 2 3 4 5 6 7
while(!sin.eof()){
char * oneChar;
oneChar = newchar [1]; // not sure what 1 means here, but it's been working
sin.read(oneChar,1);
cout.write(oneChar,1); // Correct char
delete oneChar;
}
And it would be more better if you did not allocate memory. That is if the code looks like