On 3/31/06, nalinaksh gaur <[EMAIL PROTECTED]> wrote:
>
>
> Hi everybody,
>
> I am trying to make ns2 to write some statistics to an output file.  I
> am writing the following code in some c++ file inside the ns2
> directory :
>
> #include <fstream>
> using namespace std;
> ........
> ofstream a_file ("example.txt");
> a_file<<"This text will now be inside of example.txt";
> a_file.close();
> .......
>
> Now when I 'make' ns2, I get the following error message:
>
> error: expected constructor, destructor, or type conversion before '<<'
> token
> error: expected `,' or `;' before '<<' token
> error: expected constructor, destructor, or type conversion before '.'
> token
> error: expected `,' or `;' before '.' token
>
> How can I fix this problem?
>
> Thanks!




I think that the best way to do this is write a simple agent and put it on
your destination.
Inside the function recv(Packet* pkt, Handler*), (the agent inherits the
class Agent), i've put this two line:
fstream delay_file(filename,ios::out|ios::app);
delay_file<<delay<<endl;
and it works.

Cheers

Reply via email to