![](/images/backgrounds/286549/hp-sunsoft-pascal-4-0-users-manual-549395186x1.png)
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, | #include <stdio.h> |
| ||
UseFilePtr.cc |
|
|
|
|
| extern "C" |
|
|
|
| void UseFilePtr | (FILE* ptr) | ||
| { |
|
|
|
| fprintf | (ptr, | "[1] | \n"); |
| fprintf | (ptr, | "[2] | \n"); |
| fprintf | (ptr, | "[3] | \n"); |
| } |
|
|
|
|
|
|
|
|
The C++ main program,
UseFilePtrMain.p
The commands to compile and execute UseFilePtr.cc and 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.
hostname% CC
hostname% pc UseFilePtr.o UseFilePtrMain.p hostname% a.out
[1]
[2]
[3]
162 | Pascal 4.0 User’s Guide |