=========================================================================
Date:         Thu, 13 Jun 91 12:44:46 EDT
Reply-To:     "Borland Turbo C Discussion Group at Yale"
              
Sender:       "Borland Turbo C Discussion Group at Yale"
              
From:         Lenimar Nunes 

Hello!

    I am a new user of Turbo C. I lost a lot of time trying to discover
which is the C function that is equivalent to the Pascal "CHR" and "ORD".
In Pascal, e.g.,

    Chr(92) = '\'   (or #92 = '\')       and         Ord('\') = 92.

    It may be a very simple question. Thanks for any little help.

    Lenimar Nunes de Andrade

    *** At the most oriental and sunny place in South America ***
=========================================================================
Date:         Thu, 13 Jun 91 14:06:00 -0300
Reply-To:     "Borland Turbo C Discussion Group at Yale"
              
Sender:       "Borland Turbo C Discussion Group at Yale"
              
Comments:     @FPSP.FAPESP.BR - @FPSP.HEPNET - @BRFAPESP.BITNET - .BR gateway
From:         UNBCIC%BRFAPESP.BITNET@YALEVM.YCC.YALE.EDU
Subject:      ORD in C!

There is no ORD in C because there is no need. You can do the following:
int i;
float f;
f=i='A';

In ANSI C you should do typecasting, i.e.:
f=(float) i = (int) 'A';

                              (8-DCS)
Daniel C. Sobral
UNBCIC@BRFAPESP.BITNET <--- BRFAPESP also, Mauricio!
=========================================================================
Date:         Thu, 13 Jun 91 22:50:46 EDT
Reply-To:     "Borland Turbo C Discussion Group at Yale"
              
Sender:       "Borland Turbo C Discussion Group at Yale"
              
From:         RQUAZI@CCVM.SUNYSB.EDU
In-Reply-To:  Message of Thu, 13 Jun 91 12:44:46 EDT from 

Well Lenimar, You're right it is kind of simple. In C (at least in
Turbo C) a character is stored as 1-byte, while ints are stored as
2-bytes. If you want to know the ascii value of a character you
simply do:

          printf("%d",c);       /* c is the character you want */

or if you want the character of an ascii value, simply do:

          printf("%c",asciival);     /* asciival is an int  */


Also you might want to check out the functions itoa, atoi etc.
in stdlib.h which convert strings to ints, and ints to strings.


                                          - Rishad.
=========================================================================
Date:         Fri, 14 Jun 91 09:37:00 MET
Reply-To:     "Borland Turbo C Discussion Group at Yale"
              
Sender:       "Borland Turbo C Discussion Group at Yale"
              
Comments:     This mail was sent from cluster RUUCLA using PMDF V3.0
From:         Anneke Sicherer-Roetman 
Subject:      ord/chr

There is NO equivalent for pacal's chr and ord in C because you don't need
them. For example:

Pascal:

PROGRAM test;
PROGRAM test;
PROGRAM test(output);
VAR i:integer; c:char;
BEGIN
   i:=65; c:='B';
   writeln(i,' ',chr(i),' ',c,' ',ord(c));
END.

C:

void main(void)
A
   int i; char c;

   i=65; c='B';
   printf("%d %c %c %d\n",i,i,c,c);
A

both will produce the same result. You may even assign a number to c and a
character to i if you like in the C example.

Greetings from Holland, Anneke
=========================================================================