-
-
Save tonypdmtr/cae849750376d5cc7e2028e0835e385a to your computer and use it in GitHub Desktop.
Example of Pascal record with or without variant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program a; | |
type xxx = record | |
a,b,c: char; | |
end; | |
var f: file of xxx; | |
v: xxx; | |
begin | |
assign(f,'a.dat'); | |
rewrite(f); | |
v.a := 'a'; | |
v.b := 'b'; | |
v.c := 'c'; | |
write(f,v); | |
close(f); | |
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program b; | |
type xxx = record | |
case byte of | |
0: (a: char); | |
1: (b: char); | |
2: (c: char); | |
end; | |
var f: file of xxx; | |
v: xxx; | |
begin | |
assign(f,'b.dat'); | |
rewrite(f); | |
v.a := 'a'; | |
v.b := 'b'; | |
v.c := 'c'; | |
write(f,v); | |
close(f); | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment