× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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 thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.