Solved

getting the file's name?

Posted on 2004-09-19
3
171 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
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Handling string inputs in C/Linux 23 184
How to build c program using make in mingw environment? 9 63
Unable to start eclipse ? 17 141
Raspberry Pi 3 to send text message 9 115
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

810 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