HP SunSoft Pascal 4.0 Manuale Utente Pagina 130

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 333
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 129
106 Pascal 4.0 Users Guide
6
The record in the example above has, by default, the same size and alignment
as the equivalent C record. Some records, though, are laid out differently
unless you use the -calign option.
The C main program,
StruChrMain.c
#include <stdio.h>
#include <string.h>
struct TVarLenStr {
int NBytes;
char a[25];
};
extern void StruChr(struct 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
StruChrMain.c
hostname% pc -c StruChr.p
hostname% cc StruChr.o StruChrMain.c -lpc
hostname% a.out
s25='St. Petersburg'
strlen(s25) = 13
Vedere la pagina 129
1 2 ... 125 126 127 128 129 130 131 132 133 134 135 ... 332 333

Commenti su questo manuale

Nessun commento