Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!charyb!dan From: dan@charyb.COM (Dan Mick) Newsgroups: comp.lang.c Subject: Re: C to Pascal Keywords: C to Pascal Message-ID: <356@charyb.COM> Date: 1 Feb 90 04:59:23 GMT References: <1648@milton.acs.washington.edu> Reply-To: dan@charyb.UUCP (Dan Mick) Organization: KFW Corporation, Newbury Park, CA Lines: 34 In article <1648@milton.acs.washington.edu> pingpong@milton.acs.washington.edu (jimmy) writes: >Does anyone know how to convert the following C code to Pascal code: > >int compute_num(char *word) >{ > int num=0; > while (*word) > num = (num << 5) + *word++; > return num; >} > Turbo Pascal? (strings are different than "std" Pascal). How about: TYPE string255: string[255]; function ComputeNum(word:string255):integer; num:integer; i:integer; begin for i := 1 to Length(word) do num := num * 32 + Ord(word[i]); ComputeNum := num; end; You'll have to subsitute the appropriate crud for strings and lengths and individual chars of a string otherwise, or form them yourself from a char array with a length or a null terminator, or some such. The non-standard strings in Pascal is a really silly thing.