-
December 29th, 2004, 04:42 AM
#1
Pascal to c++ translator
Hi all
Does anyone have some idea of any Translator
which can conver Pascal code to C++
Regards
Marc
-
December 29th, 2004, 08:45 AM
#2
Re: Pascal to c++ translator
Have you searched the internet? This came up almost on top,
http://www.mpsinc.com/pas2cp.html
-
November 29th, 2021, 04:12 AM
#3
Re: Pascal to c++ translator
procedure modify(var a : array [lo..hi : integer] of char);
begin
a[lo] := a[hi];
end;
procedure f(a, b : array [lo..hi : integer] of char);
begin
writeln(a[lo]);
writeln(b[lo]);
if a[lo] <> '2' then
begin
a[lo] := '1';
b[lo] := '2';
a := b;
f(a, b);
modify(a);
end
end;
procedure g(var a, b : array [lo..hi : integer] of char);
begin
writeln(a[lo]);
writeln(b[lo]);
if a[lo] = '0' then
begin
a[lo] := '3';
b[lo] := '4';
a := b;
f(a, b);
g(a, b);
end;
end;
var
a, b : array [1..100] of char;
begin
a[1] := '0';
b[1] := '0';
f(a, b);
g(a, b);
f(a, b);
writeln(a[1]);
end.
-
November 29th, 2021, 04:40 AM
#4
Re: Pascal to c++ translator
The above is Pascal. Is there a c++ question somewhere in this?
If you want this translated to c++, it's not that different. var in a function parameter means 'pass by ref'. lo,,hi for an array means the bounds - which in this case are 1..100. In C++ arrays start at 0. So if you create a and b as an char array[101] and set lo to 1 and hi to 100. You should now be able to do a translate.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|