Passing Hex...

This is a discussion on Passing Hex... within the C++ Programming forums, part of the General Programming Boards category; Sorry for the simple question... How would I pass a hex-value through a function? I mean, what type would I ...

  1. #1
    Ecologist
    Join Date
    Aug 2001
    Location
    Utah.
    Posts
    1,291

    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):
    ChangeScreenMode13();
    ChangeScreenMode03();

    I would like (1 function):
    ChangeScreenMode(0x13);
    ChangeScreenMode(0x03);

    =============================================
    int ChangeScreenMode(TYPE ScreenMode);

    What would TYPE be? Does it matter?

    Much Obliged,
    static.
    Staying away from General.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,823
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    30
    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, 01: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

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