home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / c / 12411 < prev    next >
Encoding:
Internet Message Format  |  1992-08-16  |  1.7 KB

  1. Path: sparky!uunet!cs.utexas.edu!asuvax!ncar!noao!amethyst!organpipe.uug.arizona.edu!news
  2. From: dave@cs.arizona.edu (Dave Schaumann)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Would this be the place to...
  5. Message-ID: <1992Aug17.052236.11021@organpipe.uug.arizona.edu>
  6. Date: 17 Aug 92 05:22:36 GMT
  7. References: <1992Aug8.052246.14904@mailer.cc.fsu.edu>
  8. Sender: news@organpipe.uug.arizona.edu
  9. Reply-To: dave@cs.arizona.edu (Dave Schaumann)
  10. Organization: University of Arizona
  11. Lines: 38
  12. In-Reply-To: c3460344@fsu1.cc.fsu.edu (C3460344)
  13.  
  14. In article <1992Aug8.052246.14904@mailer.cc.fsu.edu>, c3460344@fsu1 (C3460344) writes:
  15. >If I have a piece of code that I am having trouble finding a problem in, 
  16. >would I post it here?  It is about 50 or so lines...
  17.  
  18. It's been done before.  I generally read news on a 45-or-so line screen;
  19. When I see "what's wrong with this" followed by more than half a screen
  20. of code, I almost always immediatley 'n' right by it.
  21.  
  22. >I am getting garbage in the trans_type element of this structure when I 
  23. >print it to screen:
  24. >
  25. >typedef struct {
  26. >       char date[9];
  27. >       char cknum[4];
  28. >       char comment[21];
  29. >       char trans_type[4];
  30. >       float amount;
  31. >} entry;
  32.  
  33. >So, I am assuming that I am lacking some variable initialization.
  34.  
  35. Could also be field overflow; if you try to put more than 21 characters
  36. in your `comment' field, most likely it'll overflow into `trans_type'.
  37.  
  38. >How would I go about initializing an 
  39. >array full of these structures
  40.  
  41. assuming you mean constant initialization:
  42.  
  43. entry Register[MAX] = {
  44.   { "8/16/92", "100", "loan payment", "w",  200.00 },
  45.   { "8/17/92", "101", "tuition"     , "w", 1234.56 },
  46.   { "8/21/92", ""   , "pay day!"    , "d",   63.27 },
  47.   { "", "", "", "", 0.0 }
  48. } ;
  49.  
  50. -- 
  51. Dave Schaumann            dave@cs.arizona.edu
  52.