Sponsored Content
Full Discussion: EOF not found
Top Forums Programming EOF not found Post 302259128 by Corona688 on Monday 17th of November 2008 10:21:04 AM
Old 11-17-2008
I now see that getline returns a value, which may be why it doesn't throw an exception on all systems -- it can't do both at the same time, the implementor had to pick one in the event of failure. As for why EOF doesn't occur after a failed getline, I can only guess how Sun implemented their iostream. It certainly looks like it ought to produce EOF under those circumstances. So I guess you'll just need to check all return values for errors to be compatible with both. Which is probably a good idea anyway...

so your usual while loop, and with the getline, you do this:

Code:
try{
if(getline(file, buffer) <= 0)
  break;
}

which will cause the loop to break when getline fails as well as checking for exceptions.

Last edited by Corona688; 11-17-2008 at 11:33 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

EOF use

Hi, I'd like to access a windows directory from aix with samba client. To allow direct access (not interactive), i'm using EOF like: smbclient \\\\winserver\\windir 'passwd' -U usersmb << EOF cd subwindir put myfile EOF The access is correct but does somebody know how to trap errors... (1 Reply)
Discussion started by: jo_aze
1 Replies

2. Shell Programming and Scripting

Please help with EOF

Hello, you are an awesome crowd! You answered my last questions, thank you sooo much! I am trying to write a korn shell script that will record the memory my application is using (HP-UX B.11.11) and I have this: if (( $APP > $THRESHOLD )) then echo "Warning message will display" cat... (2 Replies)
Discussion started by: satraver
2 Replies

3. UNIX for Dummies Questions & Answers

Eof

hello all, how end of a file is detected in UNIX system? does it make use of any special symbols to identify the EOF? :( thank you all (5 Replies)
Discussion started by: compbug
5 Replies

4. UNIX for Dummies Questions & Answers

Eof

I have written this code: code echo 'Now choose the file or files you want to merge your input with: \c' read filenames filelist="" for file in $filenames; do filelist="$filelist $file" done echo "Now that you've chosen these files ($filelist), please start typing: " until ; do paste -... (2 Replies)
Discussion started by: fiol73
2 Replies

5. Shell Programming and Scripting

Eof

hi, in a shell script i came accross the following bit of code 1.shift $(($OPTIND - 1)) 2.if ; then 3. cat << EOF >&2 4.Usage: $0 lockfilename 5.EOF 6. exit 1 7.fi I am not able to understand the meaning of lines(1,3,5). Can any one of u tell me the purpose of above said lines.... (1 Reply)
Discussion started by: ravi raj kumar
1 Replies

6. Shell Programming and Scripting

how can i check in csh if command found or not found ?

hello all im trying to use in sun Solaris the information received from the top command now i several machines that dont have install the top program so when im running the script im geting error saying after im running this code : set MemoryInfo = `top | grep Memory` if (... (2 Replies)
Discussion started by: umen
2 Replies

7. UNIX for Dummies Questions & Answers

\n after EOF

Hello all, I have unix file that ends with the following EOF '9999999999' I want to remove the '\n' character after EOF. What is the command that should be included in the script, before sending the file? will this work: $ echo "<99999999999>\c" >> <filename> thanks in advance. (3 Replies)
Discussion started by: priya12
3 Replies

8. Shell Programming and Scripting

What is << EOF

I'm trying to connect to oracle with the following code in the script: checksqlerror{ if echo $1 exit fi } $SQLPLUS username/password@schemaname checksqlerror "failed to connect to oracle" If I'm passing wrong schema name,instead of executing checksqlerror it stops and expects user... (2 Replies)
Discussion started by: BhawanaAggarwal
2 Replies

9. Shell Programming and Scripting

Until eof do????

Hey! Can I write a routine that allows me to in a txt file check line by line until the end of file? something like until do ---some code--- done maybe it is a stupid question but I never learned shell scripts and I need this :p thanks in advance (1 Reply)
Discussion started by: ruben.rodrigues
1 Replies

10. Shell Programming and Scripting

confused with << EOF EOF

Hi friends , I am confused with << EOF EOF Most of the cases I found sqlplus $db_conn_str << EOF some sql staments EOF another exapmle is #!/bin/sh echo -n 'what is the value? ' read value sed 's/XXX/'$value'/' <<EOF The value is XXX EOF (1 Reply)
Discussion started by: imipsita.rath
1 Replies
ZZIP_ENTRY_FOPEN(3)					       zziplib Function List					       ZZIP_ENTRY_FOPEN(3)

NAME
zzip_entry_fopen, zzip_entry_ffile, zzip_entry_fread, zzip_entry_fclose, zzip_entry_feof - open a file within a zip disk for reading SYNOPSIS
#include <zzip/fseeko.h> zzip__new__ ZZIP_ENTRY_FILE * zzip_entry_fopen((ZZIP_ENTRY * entry, int takeover)); zzip__new__ ZZIP_ENTRY_FILE * zzip_entry_ffile((FILE * disk, char *filename)); zzip_size_t zzip_entry_fread((void *ptr, zzip_size_t sized, zzip_size_t nmemb, ZZIP_ENTRY_FILE * file)); int zzip_entry_fclose((ZZIP_ENTRY_FILE * file)); int zzip_entry_feof((ZZIP_ENTRY_FILE * file)); DESCRIPTION
The zzip_entry_fopen function does take an "entry" argument and copies it (or just takes it over as owner) to a new ZZIP_ENTRY_FILE handle structure. That structure contains also a zlib buffer for decoding. The zzip_entry_fopen function does seek to the file_header of the given "entry" and validates it for the data buffer following it. We do also prefetch some data from the data buffer thereby trying to match the disk pagesize for faster access later. The zzip_entry_fread will then read in chunks of pagesizes which is the size of the internal readahead buffer. If an error occurs then null is returned. The zzip_entry_ffile function opens a file found by name, so it does a search into the zip central directory with zzip_entry_findfile and whatever is found first is given to zzip_entry_fopen The zzip_entry_fread function reads more bytes into the output buffer specified as arguments. The return value is null on eof or error, the stdio-like interface can not distinguish between these so you need to check with zzip_entry_feof for the difference. The zzip_entry_fclose function releases any zlib decoder info needed for decompression and dumps the ZZIP_ENTRY_FILE struct then. The zzip_entry_feof function allows to distinguish an error from an eof condition. Actually, if we found an error but we did already reach eof then we just keep on saying that it was an eof, so the app can just continue. AUTHOR
o Guido Draheim <guidod@gmx.de> COPYRIGHT
Copyright (c) 2003,2004 Guido Draheim All rights reserved, use under the restrictions of the Lesser GNU General Public License or alternatively the restrictions of the Mozilla Public License 1.1 zziplib 0.13.62 ZZIP_ENTRY_FOPEN(3)
All times are GMT -4. The time now is 06:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy