error when using fseek() function


 
Thread Tools Search this Thread
Top Forums Programming error when using fseek() function
# 1  
Old 09-30-2004
error when using fseek() function

The errors EBADF & ESPIPE occur at this fseek call. Does anybody know how to solve this problem? Thanks in advance.

toFileStream=fdopen(localFileDes,"ra+");

if(fseek(toFileStream, 0, SEEK_END)!=0){
if(errno==EBADF)
printf("errno==EBADF\n");
if(errno==EINVAL)
printf("errno==EINVAL\n");
if(errno=ESPIPE)
printf("errno==ESPIPE\n");
}
# 2  
Old 09-30-2004
Please do not post questions in multiple forums - I deleted your other post. See the rules
# 3  
Old 09-30-2004
Driver,

For your reference, my coe should be like this and "file1.txt" is a regular file. Can you please help me to see why error occurs in this code? thanks again.

Code:
 
localFileDes=open("file1.txt", O_RDWR|O_CREAT|O_EXCL|O_APPEND);

toFileStream=fdopen(localFileDes,"ra+");

if(fseek(toFileStream, 0, SEEK_END)!=0){
if(errno==EBADF)
printf("errno==EBADF\n");
if(errno==EINVAL)
printf("errno==EINVAL\n");
if(errno=ESPIPE)
printf("errno==ESPIPE\n");
}

# 4  
Old 10-01-2004
Driver,

Thanks very much. With your help, I have solved the problem.

Ivan
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Function not found error

Hi All, I have written one shell script where I should call a function by passing variables to the actual function based on some condition. Each time I run the script I am getting the below error dsadm@bunyipd: /var/datastage/FRPDEVL/work/script> sh MClub_Validations.sh Iteration: 1... (1 Reply)
Discussion started by: tpk
1 Replies

2. Shell Programming and Scripting

Function throwing an error

Hi All I have two shell scripts where the second is getting invoked from the first. E.g. test1.sh and test2.sh Within test1, the code is something like this: #!/bin/bash . test2.sh usage() { echo "..." echo "....." } SRC=$1 DEST=$2 case "$3" in tran) doTran ;; *)... (7 Replies)
Discussion started by: swasid
7 Replies

3. UNIX for Advanced & Expert Users

error:- sh: error importing function definition for `module

Hi, We have installed linux6(RHEL) OS and installed datastage application on that. First time installation worked fine and our all services related to datastage was up and running. When we stopped the datastage and restarted its giving below error while restart:- ./uv -admin -start ... (0 Replies)
Discussion started by: prasson_ibm
0 Replies

4. UNIX for Dummies Questions & Answers

Getting a error while calling a function

Hi Friends, While calling a function in below scipt func_serv_logs () { find . -type f \( \( -name 'WLS*' -o -name 'access*' \) -a ! -name '*.gz' -a ! -newer ${REFERENCE} \) -print | while read FILENAME do echo "hi" done } func_serv_logs I am getting error... (4 Replies)
Discussion started by: Jcpratap
4 Replies

5. Programming

help with reading a binary file and fseek

this is my code and no matter what record number the user enters i cant get any of the records fields to read into the structure acct. What am i doing wrong? #include <stdio.h> typedef struct { char name; int number; float balance; } acct_info_t; int main (int... (0 Replies)
Discussion started by: bjhum33
0 Replies

6. Shell Programming and Scripting

Error with EOF when used in function

Hi all I am inserting record in oracle database using shell script. When the sql part is directly written in the shell script the record is getting inserted. But when the same piece of code is added into a function, I am getting an error while execution "line 45: syntax error: unexpected end of... (6 Replies)
Discussion started by: sudeep.id
6 Replies

7. Shell Programming and Scripting

BASH function error

Hey everyone. I am currently testing my first function based BASH script. The ultimate goal is going to be moving logs from point A to point B (or if B is down, to point C). Part of this involves the following function: function testAlive{ ping -c 1 -q $1 } Now when I run ping -c... (1 Reply)
Discussion started by: msarro
1 Replies

8. Programming

help with fseek

Hi, I working a c project in IBM AIX. I have a requirement like this. I have some contents in *temp. I am writing the contents of *temp to a file pointer ftemp (*ftemp for an tmp file tmpfile.txt) Now I want to read the contents of *ftemp in the reverse order an dneed to print it in the... (2 Replies)
Discussion started by: ramkrix
2 Replies

9. Programming

q on fseek() & ftell() + tga files

In determining the true file size of a .tga file is the fseek(fptr,0,SEEK_END); file_size = ftell(fptr); combination reliable ? The reason Im asking is because the value of file_size is in agreement with doing a wc -c mytga.tga however when I get the value of the extension... (2 Replies)
Discussion started by: JamesGoh
2 Replies
Login or Register to Ask a Question