hi ,

I was trying to open a file using fopen() method. It's not opening all the time. some time it opens but the other time its getting crashed....

FILE* tmpfile = fopen(xxxxxx, "r")

this is the code i am using....

and every time the value of xxxx is coming correctly.....

wat may be the problem...

will it occur of i try to open the file when the file is already accessed by some other function......(if so is there any lock option for it)


Please help me out.....


Regards,
Sharath.

Recommended Answers

All 2 Replies

You can get details about what happened after fopen() failure like this:

FILE* tmpfile = fopen(xxxxxx, "r");

if (!tmpfile)
{
    perror("Error opening file");
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.