home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / std / c / 2999 < prev    next >
Encoding:
Internet Message Format  |  1992-11-09  |  1.5 KB

  1. Path: sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!escargot!goanna!ok
  2. From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
  3. Newsgroups: comp.std.c
  4. Subject: Re: reg
  5. Message-ID: <15873@goanna.cs.rmit.oz.au>
  6. Date: 10 Nov 92 04:14:21 GMT
  7. References: <1992Nov5.104151.1038@dct.ac.uk>
  8. Organization: Comp Sci, RMIT, Melbourne, Australia
  9. Lines: 27
  10.  
  11. In article <1992Nov5.104151.1038@dct.ac.uk>, mcsbc2gw@dct.ac.uk writes:
  12. > Does anyone know how to pass the address of an array of structs, to a scanf
  13. > statement without it returning a NULL pointer assignment.
  14.  
  15. I guess "a scanf statement" means "an expression which is a call to scanf()". 
  16. I don't know what it means "to return a NULL pointer assignment".
  17. But most of alll, I don't understand why anyone would _try_ to pass the
  18. address of an array of structs to scanf().  There is nothing that scanf()
  19. could possibly do with it.  What kinds of arguments does scanf() want?
  20. Apart from the format control string, which is const char *,
  21. there are two kinds of arguments:
  22.     pointers to (arrays of) characters for %c, %s, and %[
  23.     pointers to SINGLE NUMBERS for the other formats.
  24. Plauger&Brodie 1989 has a nice table on p115, "Scan Format Specifiers".
  25.     
  26. If you have
  27.     struct foo {int i; float f;} arr[10];
  28. it might make sense to pass
  29.     &arr[k].i
  30. or    &arr[k].f
  31. but never (arr) on its own.
  32.  
  33. > Please can anyone help me?  I am no novice to C
  34. With the utmost possible respect, the wording of the question makes me doubt
  35. this assertion.  Why not post a larger fragment of the code, and post it to
  36. comp.lang.c?
  37.  
  38.