LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-10-2006, 11:21 PM   #1
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Rep: Reputation: 15
Question Seeking beyond the end of the file


hi,
Suppose i have a file of 100 bytes. And i have opened a file in append mode and if i do a seek of 100 bytes from there what should be the actual file size. 100 bytes or 200 bytes? Any data will be written there or not? If data is not there what will happen if we read the file? I hope i am clear.

Thanks in advance.


Regards,
Rajesh.
 
Old 08-11-2006, 01:22 AM   #2
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
I know this is going to sound annoying, but have you tried just doing a simple test? I just tried and it lets me seek past the end, and fills whatever I seeked past w/ zeroes. This is w/ the ANSI C functions (fseek and fwrite).

Last edited by 95se; 08-11-2006 at 01:24 AM.
 
Old 08-11-2006, 05:54 AM   #3
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Original Poster
Rep: Reputation: 15
yah i have tried with a sample program.
I am debugging that program. When i do a seek it returned successs. But when i do a ls on other terminal it is still showing old size only.

Regards
Rajesh
 
Old 08-11-2006, 06:19 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
The directory might only be updated when the file is closed...

Think of the output of ls as being "the last reported file-size..."
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
No new line at end of file? What does this mean? BajaNick Programming 12 05-19-2014 08:39 PM
file with ~ at the end ddaas Red Hat 5 07-13-2005 01:47 PM
Need PERL example for end of file bahadur Programming 4 05-11-2005 07:40 AM
Unexpected end of file??? raid517 Linux - Software 2 12-01-2004 04:10 AM
Script, Reading a file, When end of file? elibm Programming 2 07-16-2001 11:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration