Monday, March 22, 2010

The usage of get ( ) and put ( ) function using c++

#include // the usage of get ( ) and put ( ) function
#include
#include
void main()
{
clrscr();
char string[80];
cout<<"enter a string"<
cin>>string;
int len=strlen(string);
fstream file;
file.open("text",ios::in | ios::out);//opens a file in r/w mode
for (int i=0;i<=len;i++)
file.put(string[i]);//put a char in to a file
file.seekg(0);//go to start


char ch;
while(file)// to check for eof()
{
file.get(ch);
cout<
}
}