Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

storing data?

Status
Not open for further replies.

akashvij

Technical User
Mar 11, 2002
19
0
0
US
hi
little qur how can i dump the contents of array into a file. plz look at this
template<class T>
bool MyStorage<T>::readFromFile (char *fileName)
{
fstream fileopen(&quot;fileName&quot;,ios::in);
char arrayPtr[20];
while(!fileopen.eof())
{
fileopen.getline(arrayPtr,20);
cout<<arrayPtr<<endl;
}
fileopen.close();
return 1;
}
template<class T>
bool MyStorage<T>::printIntoFile (char *fileName)
{

fstream filewrite(&quot;fileName.txt&quot;,ios::eek:ut);
while(!filewrite.eof())
{
filewrite.put(arrayPtr);
}
filewrite.close();
return 1;
}
when i am using put function it is saying can't convert 'int' to 'char'. plz tell me what i am doin wrong.
i am working with this file.
8
7 6 3
53 23
5 3
9
 
the put i believe only &quot;puts&quot; a single character into the file. use

filewrite<<arrayPtr;

instead

Matt
 
You had better use write instead of put because put is used to write a single character.
 
thanks fellows. i will work it with out put member function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top