home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / vms / 18281 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  3.2 KB

  1. Xref: sparky comp.os.vms:18281 comp.lang.c:16925
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
  3. From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
  4. Newsgroups: comp.os.vms,comp.lang.c
  5. Subject: Re: String Pointer Passing Problem with VAX C
  6. Date: 21 Nov 1992 00:55:24 GMT
  7. Organization: HST Wide Field/Planetary Camera
  8. Lines: 44
  9. Distribution: world
  10. Message-ID: <1ek1dtINNeqa@gap.caltech.edu>
  11. References: <By1Dvp.Gpu@ux1.cso.uiuc.edu>
  12. Reply-To: carl@SOL1.GPS.CALTECH.EDU
  13. NNTP-Posting-Host: sol1.gps.caltech.edu
  14.  
  15. In article <By1Dvp.Gpu@ux1.cso.uiuc.edu>, jsivier@ux1.cso.uiuc.edu (Jonathon Sivier ) writes:
  16. =    I have run into a very wierd bug/problem.  I have a series of routines
  17. =that I am passing string (char) pointers between.  In the top level I declare
  18. =some automatic char arrays of a given size.  I then pass the pointers to these
  19. =arrays to other routines for the return of a char string.  In the routine
  20. =which is called I create the string using sprintf and place it into a local
  21. =string variable.  Before returning from the routine I copy the local string
  22. =into the argument string which was passed (I've tried both strcpy and sprintf,
  23. =the results are the same).  Upon return to the calling routine I find that the
  24. =string consists of a large number of spaces (the same number as the size of
  25. =the array) and then the string.  If the string is being returned from more
  26. =than one level down in the heirarchy of the program, the string will be padded
  27. =with that many times the number of spaces and then the actual string.
  28. =
  29. =   If, before calling the first routine in the chain, I initialize the first
  30. =array with a constant string everything seems to work.  Does this mean you
  31. =can't pass pointers to automatically created arrays?  Do only externally
  32. =declared arays of chars work when being passed between routines?  Why can't
  33. =a routine which is passed the pointer to an automatically declared array from
  34. =another routine write values into that array?
  35.  
  36. OK.  That does it.  I'm going to write up a set of guidelines for posting to
  37. comp.os.vms (a.k.a. info-vax).
  38.  
  39. One of the principal guidelines will be:
  40.     IF YOU'VE GOT A PROBLEM USING SOFTWARE YOU'VE WRITTEN YOURSELF, INCLUDE
  41.     A MINIMAL CODE FRAGMENT THAT REPRODUCES THE PROBLEM.
  42.  
  43. =   If anyone has any ideas I'd like to hear them.  Otherwise I'll have to
  44. =make all my char arrays global and that will make recursion difficult, to
  45. =say the least.
  46.  
  47. My idea is that if you give us enough information to allow us to reproduce the
  48. problem (including the version of VMS you're running, in case that matters),
  49. you'll probably get a lot more help than you will by sending a poorly-worded
  50. description of your problem.
  51. --------------------------------------------------------------------------------
  52. Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
  53.  
  54. Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
  55. understanding of astronomy is purely at the amateur level (or below).  So
  56. unless what I'm saying is directly related to VAX/VMS, don't hold me or my
  57. organization responsible for it.  If it IS related to VAX/VMS, you can try to
  58. hold me responsible for it, but my organization had nothing to do with it.
  59.