CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    126

    Pascal to c++ translator

    Hi all
    Does anyone have some idea of any Translator
    which can conver Pascal code to C++
    Regards
    Marc

  2. #2
    Join Date
    Nov 2003
    Posts
    1,405

    Re: Pascal to c++ translator

    Have you searched the internet? This came up almost on top,

    http://www.mpsinc.com/pas2cp.html

  3. #3
    Join Date
    Nov 2021
    Posts
    1

    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.

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,582

    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++20 Compiler: Microsoft VS2022 (17.0.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
  •  





Click Here to Expand Forum to Full Width

Featured