|
I don't code in RPG so I can't tell you if you're doing anything wrong on the RPG side. However, if you set a break point at the "return foo;" line, you can evaluate foo's contents by doing: eval *foo : s on the command line. This'll tell you if foo's contents are correct on the C side of things. If they are, you can focus on the RPG side of things. Elvis -----Original Message----- Subject: Re: [C400-L] Question regarding passing variables to ILE-RPG from C Good catch on that, tried changing it to have the variable global, but no effect. FOOSTR still evaluates to gibberish on the RPG side. Is there a way for me to evaluate the memory address in the module source to check foo[]'s contents? If I F11 foo in the module source, I only get an SPP:<memory address> line, rather than the actual data I was hoping to see. Thank, Pete Elvis Budimlic wrote: > Your foo variable is declared as automatic storage and is local to the > getStr function. As such, pointer you return will be valid, but the very > next instruction may very well overwrite this storage. > One way to solve it would be to declare foo as static (global) storage: > > 0001.00 #include <stdio.h> > 0002.00 #include <string.h> > 0003.00 #include <stdlib.h> > 0004.00 > 0005.00 char foo[25]; > 0006.00 > 0007.00 char* getStr(int incomingVar) > 0008.00 { > 0009.00 sprintf(foo,"%d",incomingVar); > 0010.00 return foo; > 0011.00 } > > Now the pointer you return will point to valid storage. > > Elvis >
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.