Thread: Is it ASCII value ?

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    21

    Is it ASCII value ?

    Please see this

    IMG_20170802_184645.jpg - Google Drive

    in book It is shown value of H is 74 ....what is this value ?

    as per ASCII table value of H is 72

    book is wrong ?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,674
    Yes, your book is wrong.

    Almost every book published has errors.

    Even K&R -> Errata for The C Programming Language, Second Edition * GitHub
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    99
    Quote Originally Posted by Stream View Post
    Please see this

    IMG_20170802_184645.jpg - Google Drive

    in book It is shown value of H is 74 ....what is this value ?

    as per ASCII table value of H is 72

    book is wrong ?
    Why do you care about the actual value of a char? The number could vary outside ASCII.

    For example:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void)
    {
        const char ch='H';
        printf("H value is %d\n",ch);
    
        return EXIT_SUCCESS;
    }
    The code could be tried on different Compilers and OS's and you may get varied numbers.

    Also please check the header <ctype.h>.

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    21
    Quote Originally Posted by ordak View Post
    Why do you care about the actual value of a char? The number could vary outside ASCII.

    For example:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void)
    {
        const char ch='H';
        printf("H value is %d\n",ch);
    
        return EXIT_SUCCESS;
    }
    The code could be tried on different Compilers and OS's and you may get varied numbers.

    Also please check the header <ctype.h>.
    book does not say these are ASCII ... it just says "conversion"

    What do you think? these are ASCII ?

  5. #5
    Registered User
    Join Date
    Jun 2015
    Posts
    1,643
    Quote Originally Posted by Stream View Post
    book does not say these are ASCII ... it just says "conversion"
    What do you think? these are ASCII ?
    Yes, it's ASCII, since all the other values match their ASCII values.
    Actually, today we would say that it is either ASCII or the UTF-8 encoding of UNICODE, the single-byte values of which correspond to ASCII (very convenient!).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use ASCII Art in C/C++
    By rohitdwivedula in forum C++ Programming
    Replies: 8
    Last Post: 02-26-2014, 06:36 PM
  2. ASCII character with ASCII value 0 and 32
    By hitesh_best in forum C Programming
    Replies: 4
    Last Post: 07-24-2007, 09:45 AM
  3. Ascii value
    By Saravanan.B. in forum C Programming
    Replies: 3
    Last Post: 05-08-2006, 02:12 AM
  4. ascii to str
    By wesentlich in forum C++ Programming
    Replies: 10
    Last Post: 03-15-2002, 07:43 PM
  5. Ascii
    By grade10 in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 04:51 PM

Tags for this Thread