Guys, i have made this program to create and display data of that file. But it is not working as i expected. So it would be really helpful for me if someone helps me.
The files you are opening have to exist beforehand, and you did not specify the file extension. So the files will not open. You should perform a check that the files are open. fout.is_open(), fin.is_open(). So, if the user enters Y or y, it will just ask him again. Is that what is intended?
There are some other design flaws, but for now, those are good.
Glad to see a new member! Welcome to the forum, Sainatarajan!
As well, iostream.h and fstream.h are not the correct files to use. Use iostream, and fstream.
Like so:
1 2
#include <iostream>
#include <fstream>
As well, if you want "school"(You probably want "school.txt") to exist, you need to create it first. Use a fstream instead of an istream in this case, and open the file with the ios::out flag set as well.
fstream fin("school.txt", ios::out | ios::in);
Also, you need to put
usingnamespace std; after your includes, otherwise, you must specify std:: before all your standard objects.