This blog is under construction

Saturday, 17 March 2012

toascii()

Header file:
    ctype.h

Synopsis:
    int toascii (int input);

Description:
    converts the given input to a 7-bit unsigned char value that fits into the ASCII character set, by clearing the high-order bits.

Return Value:
   returns 7 bit unsigned char value that fits into the ASCII character set.


Sample Program:

  /*
   * This example prints encodings of the 7-bit US-ASCII 
   * characters 65 to 75 are mapped to by toascii().
   */
  #include<stdio.h>
  #include<ctype.h>
  int main() {
        int c;
        for (c = 65; c <= 75; c++)
                printf("toascii(%d) : %c\n", c, toascii(c));
        return 0;
  }
 


  Output:
  jp@jp-VirtualBox:~/cpgms$ ./a.out
  toascii(65) : A
  toascii(66) : B
  toascii(67) : C
  toascii(68) : D
  toascii(69) : E
  toascii(70) : F
  toascii(71) : G
  toascii(72) : H
  toascii(73) : I
  toascii(74) : J
  toascii(75) : K


No comments:

Post a Comment