home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / question / 15919 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.0 KB  |  51 lines

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