C++ loading from txt files prob

This is a discussion on C++ loading from txt files prob within the C++ Programming forums, part of the General Programming Boards category; I wrote this code (pasted below) i'm a complete noob when i try to load it though it comes up ...

C++ loading from txt files prob

I wrote this code (pasted below) i'm a complete noob when i try to load it though it comes up with a bunch of funny characters in place of where it is supposed to show the value of bfile. I want this line here cout<< str <<"\n"; to show the value of variable no1 which has been saved into a text file earlier in the program. Instead it shows up with 3 asc11 symbols. Why is it doing this how do i fix it?

iostream.h is old and it's not used anymore. Please search the board.
Also void main should be int main. Please first close file after writing to it in order to open it for reading.
char is only 1 byte and you wrote integer (most likely 4 bytes to file). This is not what you want.

Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

Here, you open file, write to file (since by default file is opened in textual mode) and close file. For example if you enter 12, number 12 will be placed in test_int and it will be written to file as 12 (characters 1 and 2). If you open that file for reading (default mode is textual) and read only one character, it will be 1, so test_ch will contain 1 since only one character is read from file.
Does this make this issue clearer?

Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

k thx ill try closing it. I have tried it with int as well but i didnt close it first. Also int is void. If i use the int command it gives me a whole lot of errors which i cant remember exactly what they are but its something to do with the improper use of the int command. Before this i always used void and it worked fine. So i switched to void and it works. Also using namespace std; throws up errors as well so i deleted that line.

It could be because im using an old compiler? Im using microsoft developer studio version 4.