Recent

Author Topic: Multiple errors in my ported code  (Read 6826 times)

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Multiple errors in my ported code
« Reply #15 on: November 15, 2018, 12:48:31 am »
"\n" in double quotes in C is a control sequence.. It means new line..

When ever you see a"\" and a letter following it is some sort of control sequence or control character.

 to get a \ in the output text just use "\\"
 
 So a printf("\n-------\n") is this
  WriteLn; Writeln('-------------');

  of you can insert this..

 Writeln(char(13)+'--------------');


 replace the RETURNS(?) with EXIT(?)

 Replace the Do {..} while …. with Repeat …..  Until …..

 Also, arrays in C are zero based. The last time I looked they always start with 0.
 
 This should be enough to finish your homework.
The only true wisdom is knowing you know nothing

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Multiple errors in my ported code
« Reply #16 on: November 15, 2018, 08:28:03 am »
Quote
void mainloop(char c[3][3]);
void inum(char c[3][3]);
void tablero(char c[3][3]);
void inusr(char c[3][3]);
void seudoai(char c[3][3]);
int win(char c[3][3]);
The first thing I learned from C is using pointers ;)

(A little off topic)
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Multiple errors in my ported code
« Reply #17 on: November 15, 2018, 09:54:43 am »
It is also a little frustrating that OP seems to know little of both languages. Neither Pascal nor C.
Such things - that code - are really easy to translate, minutes, not hours, if you know both languages.
That's why I asked for the original C code. I think he made assumptions that are not correct.
Anyway, I could get a neat matrix on screen after cleaning up. But I'd rather have the original C sourcecode, because my working code is purely based on assumption, educated guesses if you want.
I have already volunteered to show him how such a translation should (could) be done.
« Last Edit: November 15, 2018, 09:57:24 am by Thaddy »
Specialize a type, not a var.

konniskattz

  • New member
  • *
  • Posts: 8
Re: Multiple errors in my ported code
« Reply #18 on: November 15, 2018, 12:39:56 pm »
Quote
void mainloop(char c[3][3]);
void inum(char c[3][3]);
void tablero(char c[3][3]);
void inusr(char c[3][3]);
void seudoai(char c[3][3]);
int win(char c[3][3]);
The first thing I learned from C is using pointers ;)

(A little off topic)
Yes, I know, is a code that needs a lot of optimization...

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Multiple errors in my ported code
« Reply #19 on: November 15, 2018, 03:02:43 pm »
Well? I haven't got all day?
Specialize a type, not a var.

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Multiple errors in my ported code
« Reply #20 on: November 15, 2018, 03:12:45 pm »
Starting now:...
Specialize a type, not a var.

 

TinyPortal © 2005-2018