home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!gatech!hubcap!ncrcae!grok101.ColumbiaSC.NCR.COM!raj
- From: raj@grok101.ColumbiaSC.NCR.COM (Raj Gopalakrishna)
- Subject: Re: question on fscanf
- Message-ID: <1993Jan25.102010.12775@ncrcae.ColumbiaSC.NCR.COM>
- Nntp-Posting-Host: grok101.columbiasc.ncr.com
- Organization: Your Organization Here
- References: <1993Jan22.180730.1@vax1.umkc.edu> <1jtt7jINNgj1@moe.ksu.ksu.edu>
- Date: Mon, 25 Jan 93 15:20:10 GMT
- Lines: 39
-
- In article <1jtt7jINNgj1@moe.ksu.ksu.edu>, rjq@phys.ksu.edu (Rob Quinn) writes:
- |> In <1993Jan22.180730.1@vax1.umkc.edu> srinivasan@vax1.umkc.edu writes:
- |>
- |> Mail to you bounced.
- |>
- |> In comp.unix.questions you write:
- |> > Thanks a lot for all the people who responded to my question.
- |> >I am rephrasing the question now since i found that the fopen command
- |> >si returning a valid pointer but when i do a fscanf on the file utmp
- |> >(path = /etc/utmp) then it gives a segmentation fault. Can someone
- |> >explain this phenemenon.
- What "format" string did you give fscanf() ?
-
- |>
- |> Yes, your program is broken.
- |> What more can we say with what you have given?
- Very true. Give the stack trace atleast.
-
- |> >thank you
- |>
- |> But, some ideas. When I do a 'wc -l' on my /etc/utmp I see that
- |> it has 0 lines. That means there's no terminating \n. utmp is a
- |> binary file. What do you expect to be able to scan out of it?
- A lot of commands/utilities like "who", "login" etc use utmp. It has the
- current login state of the system.
-
- |> I would bet you are scanning some huge string into a small array.
- |> Did you look at the utmp man page? If I were scanning utmp, I would
- |> use open/read/close rather than stdio.
- It can be done using any form of io calls but I guess read/write/open/close
- would be better.
-
- -raj
-
- |>
- |> --
- |> | Rob Quinn |
- |> | rjq@phys.ksu.edu |
- |> | QuinnBob@KSUVM.BITNET |
-