Monday, December 5, 2011

Re: [ns] Opening/reading files in ns-2

Hi Ricardo,

When I say I get an error message what I mean is that when I run the if statement I created I get a line on the terminal saying 'Error opening file'. At the moment I am not trying to use the file, I am just trying to get it into the code (then once I can do this I will try to use it) so everything compiles and runs ok. It's only when I created the if statement to see if conf is empty or not that my custom error message appears on the screen.

Regards,

Fraser
________________________________
Fraser Cadger (PhD Student)
Intelligent Systems Research Centre
University of Ulster (Magee)
Northland Road
BT48 7JL

Room MS216, Desk 48

Telephone: +44 (0)28 716 75173
Website: http://isrc.ulster.ac.uk/staff/FCadger/Contact.html

________________________________________
From: Ricardo S [super.ismiti@gmail.com]
Sent: 05 December 2011 12:11
To: Fraser Cadger
Subject: Re: [ns] Opening/reading files in ns-2

Hi Fraser, coud you copy-paste the error here?


On Mon, Dec 5, 2011 at 11:42 AM, Fraser Cadger
<Cadger-F@email.ulster.ac.uk> wrote:
>
> Hi,
>
> For a while I have been working with ns-2, but have only recently found the need to use file input or output operations. What I want to do is read in a txt file containing certain parameters for use in a protocol I am working on, but for some reason the fopen() command does not work.
>
> I am using the following to check whether it has been read:
>
> FILE *conf = fopen("test.txt", "r");
> if(!conf)
> {
> printf("Error opening file");
> }
>
> The test.txt file is located in the same directory as the code, so it is not in a different directory.
>
> This always returns my error message. When I copy this code and the test.txt file to another directory outside of ns-2 and compile and run it as a stand-alone application it opens the file without any problems.
>
> I am wondering whether anyone else has similar experience with this.
>
> Regards,
>
> Fraser
>
> ________________________________
> Fraser Cadger (PhD Student)
> Intelligent Systems Research Centre
> University of Ulster (Magee)
> Northland Road
> BT48 7JL
>
> Room MS216, Desk 48
>
> Telephone: +44 (0)28 716 75173
> Website: http://isrc.ulster.ac.uk/staff/FCadger/Contact.html

No comments:

Post a Comment

Counter

blogger analytics