Thread: data types

  1. #16
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by std10093 View Post
    Notice also that this makes such a non-clean code (at least in my eyes)

    Glad that I helped
    I agree.

    To the OP, you don't need to be able to store "either a letter or a number" if you are just trying to store the value of a playing card. A playing card consists of two items: a value and a suit.

    The value is easily represented as an integer 1...13 and a suit is easily represented as an integer 1..4. The card "king of spades" is just another way to say I mean the ordered pair (13,4).

    A simple way to represent an ordered pair in C is with two variables x and y. A more sophisticated way is to use a struct and reference the items myCard.value and myCard.suit for example.
    Last edited by c99tutorial; 01-13-2013 at 07:07 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. data types
    By britto116 in forum C Programming
    Replies: 12
    Last Post: 11-13-2009, 07:32 AM
  2. Data Types
    By kas2002 in forum C Programming
    Replies: 1
    Last Post: 05-21-2009, 07:30 AM
  3. data types types...
    By gftmc in forum C++ Programming
    Replies: 3
    Last Post: 09-11-2006, 11:30 AM
  4. data types
    By §elfi~ in forum C++ Programming
    Replies: 2
    Last Post: 06-26-2003, 10:23 PM
  5. data types
    By Draco in forum C Programming
    Replies: 7
    Last Post: 06-05-2002, 03:26 AM