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