difference between int and char inputs

This is a discussion on difference between int and char inputs within the C Programming forums, part of the General Programming Boards category; I've looked at various means of reading the users input, but I am sort of confused about something. If a ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    1

    difference between int and char inputs

    I've looked at various means of reading the users input, but I am sort of confused about something. If a char has an int value, and an int, a char value, what if your program is expecting either of these types of input? Since you specify how the incoming data will be formatted, how can you tell if the user intended it to be a character, or an integer?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >how can you tell if the user intended it to be a character, or an integer?
    If they intended it to be anything other than you asked for then you should print an error, or they deserve incorrect output. But in practice the equivalence of integers and characters rarely poses a problem since a wise program will read everything as character strings and break it up into individual values after validation.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  2. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  3. Display Lists (OpenGL)
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 06-05-2005, 12:11 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21