Hi all..

I want to know the file descriptor of a file that I have opened in my program.

I know open(char*,int,int) returns a file descriptor.

What if use fstream out("...").. Is there any way to know the file descriptor this way??

thnx.

What would you do with the information if you had it?

(: [...I'm not gonna take over the world with it..!!]

I want to try out mmap() function.. and it requires me to specify a file descriptor to the file which is to be mapped...

so, if I had the information, I'll put it inside mmap()..

But mmap() is not part of C++. For that matter, neither are file descriptors. So what you're really saying is that you want to use information that your particular implementation provides in an implementation-dependent way.

Which means that the answer to your question relies on the details of your implementation.

ok...
is there any specific reason that file descriptors are not a part of c++??

and..if i want to do something like mmap() in c++, what should i do?

ok...
is there any specific reason that file descriptors are not a part of c++??

and..if i want to do something like mmap() in c++, what should i do?

File descriptors are not part of C++ because if they were, how would C++ be implemented on an operating system that does not have them? Ditto mmap().

So if you want to use such facilities, you have to consult the documentation for your particular implementation and find out how, and whether, the implementation has made them available.

ok...
also.. I tried implementing mmap() in a c program..
mmap() runs fine... but when I try using the corresponding pointer it returns, i get bus error..
how can i fix this?

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.