Q: formatted integer extraction from ifstream

J

James Lehman

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:)
 
P

Pavel

James said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top