Hi
I have a file pointer which is pointing to a file in the physical disk. Now I wanted to know which file it is pointing to. Is there a way to print it using file pointer.
Regards
Padma
3 24457 RRick 463
Recognized Expert Contributor
The simplest way is to get the program in the debugger and look at the file pointer.
GNU will let you see the values, but I doubt it will help you. For the following program - #include <stdio.h>
-
-
int main( void)
-
{
-
FILE * file = fopen( "t.c", "r");
-
-
printf ( "FILE: %p\n", file);
-
}
When stopped at line 7, the debugger says: -
(gdb) p *file
-
$3 = {
-
_flags = -72539000,
-
_IO_read_ptr = 0x0,
-
_IO_read_end = 0x0,
-
_IO_read_base = 0x0,
-
_IO_write_base = 0x0,
-
_IO_write_ptr = 0x0,
-
_IO_write_end = 0x0,
-
_IO_buf_base = 0x0,
-
_IO_buf_end = 0x0,
-
_IO_save_base = 0x0,
-
_IO_backup_base = 0x0,
-
_IO_save_end = 0x0,
-
_markers = 0x0,
-
_chain = 0x70d480,
-
_fileno = 7,
-
_flags2 = 0,
-
_old_offset = 0,
-
_cur_column = 0,
-
_vtable_offset = 0 '\0',
-
_shortbuf = "",
-
_lock = 0x8ae40a0,
-
_offset = -1,
-
__pad1 = 0x0,
-
__pad2 = 0x8ae40ac,
-
_mode = 0,
-
_unused2 = '\0' <repeats 51 times>
-
}
-
I don't see a lot of useful information here.
Banfa 9,065
Recognized Expert Moderator Expert
I have a file pointer which is pointing to a file in the physical disk. Now I wanted to know which file it is pointing to. Is there a way to print it using file pointer.
Yes store the name of the file that you opened when you open it.
Banfa 9,065
Recognized Expert Moderator Expert
I don't see a lot of useful information here.
Not to mention that that information would be platform dependent and not guaranteed to be the same on all systems (although it probably would be the same on all systems running the same OS on the same hardware).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Martin Bless |
last post by:
Why can't we have an additional 'print' statement, that behaves
exactly like 'print' but doesn't insert that damn blank between two
arguments?
Could be called 'printn' or 'prin1' or 'prinn' anything similar you
like.
Would make my life so much easier. Often I start with a nice and short
print statement, then there happen to be more...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen. It is
almost like it is trying to implement it's own COM interfaces...
below is the header, and a link to the dll+code:
Zip file with header,...
|
by: Ed Bitzer |
last post by:
I can locate tab stops in a RichTextBox but have not found a way to
maintain that positioning when I print. At the Knowledge Discovery
Keys Site (http://www.kdkeys.net/forums/3122/ShowPost.aspx) Baily
explains that character printing isn't really supported in VB .Net,
the TAB method does not apply. The DrawString method is used to send...
|
by: Peter Lin |
last post by:
Hey,
I am just wondering if anyone has got any idea of setting up a new class
so that you could just print like the old ways with the printer class,
since I am writing a program that really requires simple black and white
text printing, but there is alot to print and it's needed at various
places, which is why I find that the new printing...
|
by: Bill_DBA |
last post by:
I have the following stored procedure that is called from the source of
a transformation in a DTS package. The first parameter turns on PRINT
debug messages. The second, when equals 1, turns on the openning,
fetching, and closing of a cursor. Things are fine if only one of the
two parameters was set to 1.
When run with both parameters...
| |
by: sam_cit |
last post by:
Hi,
I hear many say that it is better to convert address, i mean, type
cast into (void*) and print using %p identifier rather than %u, could
you let me know the specific reason behind it?
|
by: scoobydoo666 |
last post by:
Hi
Could any one tell me how to print size of char pointer array?
for example
char *ptrArray=new;
cout<<sizeof(ptrArray);
The above code will print 4 (pointer size) instead of 25. how do I print 25?
Thanks in advance
|
by: zackp |
last post by:
Hello,
I am learning C++ lately. This morning, out of curiosity I
constructed a simple code below, but to my surprise, when char* is
used, the program fails to print almost anything.
The only thing I got is the following:
% : np =
As soon as I use a pointer to another type, everything behaves as
|
by: arnuld |
last post by:
I have created a program to print the input words on stdout. Input is
taken dynamically from stdin. In each word, each input character is
allocated dynamically. I have ran this program with a file containing a
*single* word made of 25525500 letters and this program works fine on it.
I will welcome any suggestions for improvement.
/* * A...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |