Thread: Passing Hex...

  1. #1
    Join Date
    Aug 2001

    Passing Hex...

    Sorry for the simple question...

    How would I pass a hex-value through a function?
    I mean, what type would I use?

    Currently I have two different functions. One
    is used to change the screen resolution to 13h,
    and the other is to change it back to 03h. I would
    like to only have one function and pass the
    screen-mode through that.

    Instead of (2 seperate functions):

    I would like (1 function):

    int ChangeScreenMode(TYPE ScreenMode);

    What would TYPE be? Does it matter?

    Much Obliged,
    Staying away from General.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    unsigned int is a good bet

    Or any other unsigned integer type will do

    Any signed integer type will probably do for this specific example, but you might get the odd compiler warning if you try and pass a hex value with the most significant bit set (the function will think its a negative value)
    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
    Nov 2001
    Vid modes never even come close to FFh, so a short int would actually work fine. An integer is just a particular range of numbers. The base those numbers are in is irrelevant as long as the number is w/ in the range.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ascii to hex and hex to Ascii
    By beon in forum C Programming
    Replies: 1
    Last Post: 12-26-2006, 06:37 AM
  2. Hex Editing help and information please...
    By SG57 in forum C Programming
    Replies: 9
    Last Post: 06-25-2006, 12:30 AM
  3. Replies: 11
    Last Post: 03-24-2006, 11:26 AM
  4. Replies: 3
    Last Post: 01-23-2006, 07:25 PM
  5. Is binary HEX?
    By Budgiekarl in forum Tech Board
    Replies: 11
    Last Post: 11-23-2003, 09:02 AM