- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- File Pointers
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 01:54 AM
тАО07-27-2005 01:54 AM
1) I declare 2 file pointers -
FILE *fp1, *fp2;
2) Using 'fp1' I open a file for reading in binary mode -
fp1=fopen("test","rb");
3) I use 'fp2' to point to same memory what fp1 is pointing to -
fp2=fp1;
4) Using 'fp2' I read a record from the file 'test' using a structure -
fread(&rec,sizeof(struct st),1,fp2);
Question -
What is the impact on pointer 'fp1' after step #4 is executed? Where will 'fp1' point to?
My Observation -
After step #4 is executed, 'fp2' should be at the end of 1st record that is read. and since 'fp1' is never used it should still be pointing to the beginning of the file. but it does not work that way. what i find is though 'fp1' is not used, it too is at the end of the 1st record along with 'fp2'.
i want 'fp1' to remain at the beginning of the file untill i position it. is this something that i could achieve? pl help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 02:07 AM
тАО07-27-2005 02:07 AM
Re: File Pointers
Since something of the type FILE * is a pointer to something (in this case an object of the opaque type FILE), it is only natural that if an operation changes something in that object, both pointers to the same object reflect those changes.
You might want to read on the functions fseek() and ftell(); these can be used to (re)position the read/write marker in a file.
Regards,
Kris (aka Qkcl)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 02:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 10:01 AM
тАО07-27-2005 10:01 AM
Re: File Pointers
Opening the file twice will do what you want. HOWEVER, you need to open the file with shared access. The two opens from the same process are seen in the same way as opens from multiple processes - hence shared access is required.
If you used RMS I/O you could OPEN the file once and CONNECT multiple streams. This would allow you to maintain multiple pointers into the file, but with exclusive access. Native C I/O doesn't have a way to access multiple RMS streams (BASIC and COBOL do).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 05:11 PM
тАО07-27-2005 05:11 PM
Re: File Pointers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 05:40 PM
тАО07-27-2005 05:40 PM
Re: File Pointers
There are a number of examples in SYS$EXAMPLES showing various
features of RMS.
The documentation can be found by following the link at the
bottom of the main page for this forum.
http://h71000.www7.hp.com/doc/index.html
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 05:44 PM
тАО07-27-2005 05:44 PM
Re: File Pointers
The RMS reference manual is at
http://h71000.www7.hp.com/doc/731FINAL/4523/4523PRO.HTML
which covers all the services and has various
examples, some in C.
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 06:47 PM
тАО07-27-2005 06:47 PM
Re: File Pointers
RMS programming is not simple and (in this case) can't help.
Neither fopen(), neither fread() of standard c-runtime doesn't lock record.
Using of RMS is useful to manage indexed files, not binary/stream flushes.
Full working example is attached.
Antonio Vigliotti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:05 PM
тАО07-27-2005 07:05 PM
Re: File Pointers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:09 PM
тАО07-27-2005 07:09 PM
Re: File Pointers
will list all the C programs.
$ type/page sys$examples:alpha_logger.c
will list alpha_logger.c
You may find it easier to look at the examples
in the documentation.
Dave