Thursday, October 13, 2011

C++ example program to write contents to a text file.




  Below is the simple c++ example program, to read contents from a text file stored in your computer's hard drive...





#include<iostream.h>
#include<fstream.h>
void main()
{
 char *name;
 int num;
 ofstream fileout;
 fileout.open("d:\\cpp\\pgm\\a.txt");
 cout<<"Enter the name"<<endl;
 cin>>name;
 cout<<"Enter number"<<endl;
 cin>>num;
 fileout<<name<<endl;
 fileout<<num<<endl;
 fileout.close();
}



Hope this helps..

                                                                                                                                        Techytips

Reactions:

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons