473,770 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: formatted integer extraction from ifstream

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. :o)

Apr 23 '06 #1
1 2337
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. :o)

Yes, it's pretty easy to set up:
is.setf(ios::fm tflags(0), ios::basefield) ;
-Pavel
Apr 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3035
by: The Roys | last post by:
Hi I have a textbox which displays a formatted numeric. eg: 100,000 When I retreive this value for calculations, it is valued at 100 eg: calc = val(txtbox) * 2 calc will equal 200, not 200,000. Why is this, how do I fix it ??
18
2581
by: Kevin Grigorenko | last post by:
Okay, i've got a file open, call it infile. I've got a simple while(!eof), but say the first line of my file is "<?xml version="1.0">", then it takes two iterations to get the string. first 'line' is "<?xml", then 'line' is "version="1.0"", what's happening that I need to change the behavior of so that I can get lines delimitted by the newlines in the file? std::string line; std::ifstream infile("whatever.txt", std::ios_base::in);...
2
3509
by: Steven T. Hatton | last post by:
I'm still not completely sure what's going on with C++ I/O regarding the extractors and inserters. The following document seems a bit inconsistent: http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#1 Copying a file: WRONG WAY: #include <fstream> std::ifstream IN ("input_file"); std::ofstream OUT ("output_file");
13
3658
by: coinjo | last post by:
Is there any function to determine the length of an integer string?
4
2638
by: jm0 | last post by:
Hi, im developing this program, and then i ran into some trouble "oooh no!" hate to ask.. have search google and this page for something to spilt things up in arrays or whatever can be used, spent my half day trying to find a solution, but nothing :( then i agreed with my self that i have to ask. So her's the question/problem. Link to project: http://kawsper.dyndns.dk/~jmo/development/c++/projects/n0rdnat/ I have a data file called...
4
16235
by: Gary Wessle | last post by:
Hi I am writing a code to open a space delimited data file, return the number of rows and columns, as well as return the nth column where n is user define number. I put all the cells in a loooong vector and loop in an incremental way to select the column of choice, here is the code which works but gives a warning ****************************************************************
7
2487
by: pkirk25 | last post by:
My data is in a big file that I have no control over. Sometimes its over 30 MB and often there are several of them. It is machine generated and is nicely formatted. Example text follows: AuctioneerSnapshotDB = { = { = 20, = 1, = {
7
3910
by: zhouchengly | last post by:
when I use the following code to get integer values from file: void getIntegers() { vector<ItemType items; ifstream ifs("test.dat"); //¿¼ÂÇΪitemsÒ»´Î·ÖÅä¿Õ¼ä¡£ ItemType item ; while( !ifs.eof() ) { ifs>>item;
4
9176
by: Steve Rainbird | last post by:
Is there a way in DB2 I can get the current date and time formatted. In Oracle I could do the following select to_char(sysdate,'yyyymmdd') from dual returns 20070718
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.