Q: formatted integer extraction from ifstream

Discussion in 'C++' started by James Lehman, Apr 23, 2006.

  1. James Lehman

    James Lehman Guest

    Hello.

    I want to write a program that reads AutoCAD shape (font) files. They are
    written with the convention that hexadecimal values have a leading zero and
    decimal values do not. All numbers can be negative or positive. All numbers
    can be stored in a single byte. My questions is: can ifstream extraction
    into an int see the leading zero and interpret the number as hex and can I
    ask the ifstream, right after the extraction, if the value I got was hex or
    dec? Or do I have to peek for the possible sign and leading zero and set the
    stream format to hex?

    Thanks! James. :eek:)
     
    James Lehman, Apr 23, 2006
    #1
    1. Advertising

  2. James Lehman

    Pavel Guest

    James Lehman wrote:
    > Hello.
    >
    > I want to write a program that reads AutoCAD shape (font) files. They are
    > written with the convention that hexadecimal values have a leading zero and
    > decimal values do not. All numbers can be negative or positive. All numbers
    > can be stored in a single byte. My questions is: can ifstream extraction
    > into an int see the leading zero and interpret the number as hex and can I
    > ask the ifstream, right after the extraction, if the value I got was hex or
    > dec? Or do I have to peek for the possible sign and leading zero and set the
    > stream format to hex?
    >
    > Thanks! James. :eek:)
    >
    >
    >

    Yes, it's pretty easy to set up:
    is.setf(ios::fmtflags(0), ios::basefield);
    -Pavel
     
    Pavel, Apr 23, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    CType(x,Integer) vs. Integer.Parse(x)

    =?Utf-8?B?Sm9l?=, Feb 6, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    5,957
    =?Utf-8?B?RGF2aWQgQW50b24=?=
    Feb 7, 2006
  2. =?ISO-8859-1?Q?Thomas_Gagn=E9?=

    No Math.min(Integer, Integer)?

    =?ISO-8859-1?Q?Thomas_Gagn=E9?=, Jul 29, 2003, in forum: Java
    Replies:
    0
    Views:
    511
    =?ISO-8859-1?Q?Thomas_Gagn=E9?=
    Jul 29, 2003
  3. silly
    Replies:
    2
    Views:
    384
    silly
    Nov 11, 2003
  4. yingmu

    ifstream reading integer problem

    yingmu, Nov 13, 2006, in forum: C Programming
    Replies:
    1
    Views:
    7,683
    PraveenAyinikkal
    Nov 14, 2006
  5. Replies:
    7
    Views:
    2,700
    Ivan Vecerina
    Nov 7, 2006
Loading...

Share This Page