or use following option in fscanf to read till end of line :

      fscanf ( fp,  "^{\n] ",   filename);

Lalit
 

[EMAIL PROTECTED] wrote:

Hi
     instead of the "fscanf" u can use "fgets" scan one line each and every
time.
          like as follows:
          char buf[256];

     fgets(buf,255,fp);
     fp -> file pointer.

     here it scans 255 chars or one line. whichever comes first.

     If ur line is too big , in such case 2nd argument, u can give more like
this: 1024 or 2048.

          read system call never returns line basis, reads a certain number of
bytes and returns it back.

          error value .i.e "Bad address" is due to error code: EFAULT.
          This will be set when the argument ( buffer ) is not accessible.

          This means buffer is outside your accessible address space. This means
to say that while writting to ur buffer,
          either ur buffer is pointing invalid address or at that moment ur
"buffer" page has swapped out.

          Make sure to pass the valid buffer address to this system call.

Regards,
Ramki kvv.

"Manish K Arya" <[EMAIL PROTECTED]> on 05/15/2002 11:42:10 AM

Please respond to [EMAIL PROTECTED]

To:   "linux programmers" <[EMAIL PROTECTED]>,
      "general linux" <[EMAIL PROTECTED]>
cc:    (bcc: Veera R Koduri/HSS)

Subject:  [ilugd]: read error

hi
    i was trying to read output of tail -f by follow method
    i first filtered out put of logs and redirted to a file like
     tail -f /var/log/messages | grep firewall > firewall.log &

then i tried to read firewall.log by

1)fscanf()
   it read the file but i used %s so i was not able to get complete line of log
   can some one tell me what shall i give in place of %s if get complete line
scanned

2)read()
   i opened file in Readonly mode.it opened successfully
   but when i try to read it i get "Bad Address" (i m using perror())

pls help
---
Manish Kumar Arya

________________________________________________________
Outgrown your current e-mail service?
Get a 25MB Inbox, POP3 Access, No Ads and No Taglines with LYCOS MAIL PLUS.
http://login.mail.lycos.com/brandPage.shtml?pageId=plus

          ================================================
To subscribe, send email to [EMAIL PROTECTED] with subscribe in subject
header
To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject
header
Archives are available at http://www.mail-archive.com/ilugd%40wpaa.org
          =================================================

          ================================================
To subscribe, send email to [EMAIL PROTECTED] with subscribe in subject header
To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject header
Archives are available at http://www.mail-archive.com/ilugd%40wpaa.org
          =================================================

-- 

*******************************
LALIT KUMAR BHASIN
WIPRO TECHNOLOGIES
GURGAON.
Ph. 0124-6398465-69 Ext 2019
    9810419594
********************************
 
**************************Disclaimer************************************

Information contained in this E-MAIL being proprietary to Wipro Limited
is 'privileged' and 'confidential' and intended for use only by the
individual or entity to which it is addressed. You are notified that any
use, copying or dissemination of the information contained in the E-MAIL
in any manner whatsoever is strictly prohibited.


******************************************************************

Reply via email to