HP SunSoft Pascal 4.0 Uživatelský manuál Strana 186

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 333
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 185
162 Pascal 4.0 Users Guide
7
Pascal File Pointers to C++
You can pass a file pointer from Pascal to C++, then have C++ do the I/O. See
this example.
The C++ procedure,
UseFilePtr.cc
#include <stdio.h>
extern "C"
void UseFilePtr (FILE* ptr)
{
fprintf (ptr, "[1] \n");
fprintf (ptr, "[2] \n");
fprintf (ptr, "[3] \n");
}
The C++ main program,
UseFilePtrMain.p
program UseFilePtrMain (output);
var
f: text;
cfile: univ_ptr;
procedure UseFilePtr (cf: univ_ptr); external C;
begin
rewrite (f, 'myfile.data');
cfile := getfile (f);
UseFilePtr (cfile);
end.
The commands to compile and
execute UseFilePtr.cc and
UseFilePtrMain.p
hostname% CC -c UseFilePtr.cc
hostname% pc UseFilePtr.o UseFilePtrMain.p
hostname% a.out
[1]
[2]
[3]
Zobrazit stránku 185
1 2 ... 181 182 183 184 185 186 187 188 189 190 191 ... 332 333

Komentáře k této Příručce

Žádné komentáře