HP SunSoft Pascal 4.0 User Manual Page 171

  • Download
  • Add to my manuals
  • Print
  • Page
    / 333
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 170
The C++–Pascal Interface 147
7
The C++ main program,
StruChrMain.cc
#include <stdio.h>
#include <string.h>
struct TVarLenStr {
int NBytes;
char a[25];
};
extern "C" void StruChr (
TVarLenStr &);
int main(void)
{
struct TVarLenStr vls;
char s25[25];
vls.NBytes = 0;
StruChr (vls);
strncpy (s25, vls.a, vls.NBytes);
printf ("s25 = '%s' \n", s25);
printf ("strlen (s25) = %d \n", strlen(s25));
}
The commands to compile and
execute StruChr.p and
StruChr.cc
hostname% pc -c StruChr.p
hostname% CC StruChr.o StruChrMain.cc -lpc
hostname% a.out
s25 = 'St.Petersburg'
strlen (s25) = 13
Page view 170
1 2 ... 166 167 168 169 170 171 172 173 174 175 176 ... 332 333

Comments to this Manuals

No comments