7

The C++ main program,

DayWeatherMain.cc

#include <stdio.h> #include <string.h>

struct TDayRec { char TDay[9]; char TWeather[21];

};

extern "C" void DayWeather ( TDayRec [2],

int &);

int main(void)

{

struct TDayRec dr[2]; int NBytes;

char s25[25]; char t25[25]; NBytes = 0; DayWeather (dr, NBytes);

strncpy (s25, dr[1].TDay, 6); printf (" day = '%s' \n", s25); strncpy (t25, dr[1].TWeather, NBytes); printf (" weather = '%s' \n", t25);

}

The C++–Pascal Interface

149