Sun Microsystems SunSoft Pascal 4.0 User Manual page 131

Hewlett-packard user guide printer printer
Table of Contents

Advertisement

The Pascal routine,
DayWeather.p
The C main program,
DayWeatherMain.c
Consider this example:
type
TDayWeather = record
TDay: array [0..8] of char;
TWeather: array [0..20] of char;
end;
TDayWeatherArray = array [0..1] of TDayWeather;
procedure DayWeather(var W: TDayWeatherArray;
begin
W[1].TDay := 'Sunday' + chr(0);
W[1].TWeather := 'Sunny' + chr(0);
WeatherSize := 5;
end;
{ StruChr }
#include <stdio.h>
#include <string.h>
struct TDayRec {
char TDay[9];
char TWeather[21];
};
extern void DayWeather(struct TDayRec [], int *);
int main(void)
{
char s25[25];
char t25[25];
struct TDayRec dr[2];
int 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
var WeatherSize: integer);
6
107

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the SunSoft Pascal 4.0 and is the answer not in the manual?

Questions and answers

Table of Contents