-
July 4th, 2005, 03:03 AM
#1
I/o
i am trying to get parameters from function ,i want to write that parameters to the file.
let file name be ,say "logfile"
parameters are of type wchar_t
i am using
ofstream("filename",ios::app) for appending the data.
now how should i write the parameters to the file logfile?
i m trying to use one function which will get one parameters at a time and write that to file logfile.
but how should i write the parameters to the file?
can anyone explain with some code?
-
July 4th, 2005, 06:58 AM
#2
Re: I/o
Quoted by swapnil Jul 2005, Posts: 1
but how should i write the parameters to the file?
I am trying to guess your problem. Suppose u have two parameters say Param1 and Param2.You can write in following way
Code:
outfile<<"PARAM1"<<"\t"<<Param1<<endl;
outfile<<"PARAM2"<<"\t"<<Param2<<endl;
//supposing ofstream outfile(.....)
Output will be
PARAM1 value
PARAM2 value
To read them back, you may do
Code:
infile>>str;
if(str=="PARAM1") infile>>Param1;
else if(str=="PARAM2") infile>>Param2;
///supposing ifstream infile(...)
but how should i write the parameters to the file?
Just writing their value in file. If reading and writing order is always same, doesn't need any extra information, otherwise also add some information with value so that we can read it later ( As I try to show above).
Last edited by upashu2; July 4th, 2005 at 07:03 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|