HP SunSoft Pascal 4.0 Manual de usuario Pagina 128

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 333
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 127
104 Pascal 4.0 Users Guide
6
If wc is the width of the smallest element, as determined by sizeof(), then
the width of the next largest element is the number of those smaller elements
in the next larger element multiplied by wc.
width of next largest element = (ub - lb + 1) * wc
In general, (lb, ub, wc) are the bounds and element width of the next lower
dimension of the array. This definition is recursive.
Example 3: Array of Characters
The commands to compile and
execute RealCA.p and
RealCAMain.c with -calign
hostname% pc -c -calign RealCA.p
hostname% cc RealCA.o RealCAMain.c -lpc
hostname% a.out
1.0 0.0 0.0
0.0 1.0 0.0
The Pascal procedure,
ChrCAVar.p
procedure ChrCAVar(var a: array [lb..ub: integer] of char);
begin
a[0] := 'T';
a[13] := 'o';
end; { ChrCAVar }
The C main program,
ChrCAVarMain.c. For C, the
lower bound is always 0.
#include <stdio.h>
extern void ChrCAVar(char [], int, int);
int main(void)
{
static char s[] = "this is a string" ;
ChrCAVar( s, 0, sizeof(s)-1) ; /*(s, lower, upper)*/
printf("%11s \n", s) ;
}
Vista de pagina 127
1 2 ... 123 124 125 126 127 128 129 130 131 132 133 ... 332 333

Comentarios a estos manuales

Sin comentarios