Thursday, October 13, 2011

C++ example program to read contents from 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;
 ifstream filein;
 filein.open("d:\\cpp\\pgm\\a.txt");
 filein>>name;
 filein>>num;
 cout<<name<<endl;
 cout<<num<<endl;
 filein.close();
}


Hope this helps..

                                                                                                                                          Techytips

1 comments:

trustno1 said...

cplusplus samples to starters
c++ sample - Single linked list

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

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