[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

getting the file's name?

Posted on 2004-09-19
3
Medium Priority
?
177 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 100 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 100 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

656 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