Solved

getting the file's name?

Posted on 2004-09-19
3
174 Views
Last Modified: 2010-04-15
I am trying to get the file's name in this this way.

void do_more( FILE *fp)
{
        printf(fp);
...
}
Is this possible to do or i have to find a different way?
Thanks
0
Comment
Question by:Carl3003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Accepted Solution

by:
efn earned 25 total points
ID: 12099286
You have to find a different way.  Normally, you keep track of the name as a character string separate from the FILE pointer.
0
 
LVL 45

Assisted Solution

by:sunnycoder
sunnycoder earned 25 total points
ID: 12099392
Hi Carl3003,

You would have specified the file name somewhere when you obtained the FILE * fp. You will have to use that. There is no ANSI C function which will give you the file name when you supply the FILE *.

There are some other platform specific solutions such as examining ls -l /proc/<pid>/fd on various flavours of linux. However, I will still recommend using the information yuo already have rather than fish for it in an unportable way.

cheers
sunnycoder
0
 

Author Comment

by:Carl3003
ID: 12102847
yes, i past the char array and then print the file name..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question