C++ Program to Read and Write a Text File

#include<iostream.h>
#include<fstream.h>
int main()
{
 ofstream outf("ITEM");
 cout<<"Enter item name:";
 char name[30];
 cin>>name;
 outf<<name<<"\n";  // write to file ITEM 
 cout<<"Enter item cost:";
 float cost;
 cin>>cost;
 outf<<cost<<"\n";
 outf.close();
 ifstream inf("Item");
 inf>>name;   // read name from file ITEM 
 inf>>cost;   // read cost from file ITEM 
 cout<<"\n";
 cout<<"Item name:"<<name<<"\n";
 cout<<"Item cost:"<<cost<<"\n";
 inf.close()
 return 0;
}