From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c4d884378fc6b03c,start X-Google-Attributes: gid103376,public From: Ding-yuan Sheu Subject: Two questions Date: 1996/11/07 Message-ID: <32825177.41C6@afit.af.mil>#1/1 X-Deja-AN: 195142598 cc: mkanko@afit.af.mil, kshomper@afit.af.mil, lawlis@afit.af.mil,dsheu@afit.af.mil content-type: text/plain; charset=us-ascii organization: Air Force Institute of Technology mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01S (X11; I; IRIX 6.2 IP22) Date: 1996-11-07T00:00:00+00:00 List-Id: Hello All, I am converting a C++ application into Ada95 and ran into two problems. If you know the answers, please let me know. I appreciate your any help. (1) Is there an easy way to achieve the same result of the C++ sprintf function in Ada? I know this may be a FAQ. Your patience and kindness are appreciated. I work on my project on SGI machines. SGI provides some C++ library binding for Ada programers. However, for the sprintf function, I think the binding interface is unclear. So, I don't know how to use it. If you happen to know how to use it. Please let me know. (2) In a C++ function, prorammers can declare a static local variable to preserve its value between function calls. Can I do that in Ada? For example, in C++, I can write a function as follows: void strcount(char *str) { static int total =0; int count = 0; while (*str++) count++; total = total + count; } Whenever strcount is called, the value of total will not be reinitialize to 0. It will preserve the value after it was called last time. I know I can use a package to wrap strcount and declare a private variable in the package to achieve the same result. However, is this the only solution? Can I simply declare a static variable in the Ada subprogram to achieve the same result? Any comments are welcomed. Thanks in advance. ====================================================================== Ding-yuan Sheu (Steven) | Student of Air Force Institute Technology (513)233-2022 | for Master Degree of Computer System dsheu@afit.af.mil | Software Engineering Sequence