473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how does fseek work with the set of arguments specified as below?

hello everybody,
i want to know that if i use the statement fseek(fp,column-3,1); in my program where fp is the file pointer,column-3 is the no of columns specified by the user
-3 and third argument is 1. please explain me where will the file pointer be placed after this statement gets executed.this is urgent if possible please tell me as soon as possible.thankyou.
Apr 16 '07 #1
3 3487
weaknessforcats
9,208 Expert Mod 8TB
From position 1 in the file (the SECOND byte), add the value in column-3.

Now the question is: Does your column-3 contain the NUMBER of columns or the number of bytes in the number of columns?

fseek ASSUMES the second argument is the OFFSET from the third argument.
Apr 16 '07 #2
From position 1 in the file (the SECOND byte), add the value in column-3.

Now the question is: Does your column-3 contain the NUMBER of columns or the number of bytes in the number of columns?

fseek ASSUMES the second argument is the OFFSET from the third argument.
thanks a lot much for clearing my doubt. but the question you ve put i need an answer to that also.i think it should be no of columns but the data i am using is integers so it might also be no of bytes in the no of columns.i am using this pointer for an array of integers.so please tell me that what assumtion should i make.
Apr 17 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
Do not make assumptions. If your columns are integers and you have N integers in the columns, then the column size is:

N * sizeof(int)

If you have Y columns, then the size of those columns is:

Y * N * sizeof(int)

That is what you use in fseek.
Apr 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Alex | last post by:
Rossum's tutorial on Python states: "open() returns a file object, and is most commonly used with two arguments: 'open(filename, mode)' mode 'r+' opens the file for both reading and writing." ...
62
by: Christopher Benson-Manica | last post by:
On thinking about the "replace a word in a file" thread, I wondered how easy it would be to accomplish the same thing with only one file pointer. This led me to some questions... "For a text...
10
by: Orion | last post by:
Hey, I was wondering if it was possible to determine if you hit 'EOF' using fseek? I'm using fseek to traverse through the file from start to end and capturing the data into a linked list...
5
by: Stephen Mayes | last post by:
#include <stdio.h> #include <stdlib.h> #include <string.h> int main (void) { static char * contents = "Line1\nLine2\nLine3\nLine4"; FILE * tmp; char readbuf; size_t len, n = 0;
2
by: cedarson | last post by:
I am writing a program and have been instructeed to use the 'fseek', 'ftell', and 'stat' functions, however, after looking in the online manual for each of these, I am still unsure on how to use...
6
by: ericunfuk | last post by:
I have posted a few other posts before this one today, I still can't solve my problem, I think I need to elaborate my problem now. I'm trying to send a file using UDP, below is a segment of my...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
4
by: melisa | last post by:
I'm writting a method which will start a new specified program and specified file e.g start testdoc.doc with WINWORD.exe as below: private void Start_Process() { ProcessStartInfo startInfo =...
32
by: Stephen Horne | last post by:
I've been using Visual C++ 2003 for some time, and recently started working on making my code compile in GCC and MinGW. I hit on lots of unexpected problems which boil down to the same template...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.