So I'm trying to read some data from a file, which includes hex numbers
of a known length (In my specific case, 6). I know there are more
indirect ways to do this, but I was hoping I could do it more directly.
For example, I want to read in the first 6 characters in this string as
a hex number:
0000FF123456
I was hoping I could do something along the lines of
int x;
ifstream file;
// Open the file, etc.
file >setw(6) >x;
The problem is, it ignores the 0s - x will have the value 0xFF1234
(Instead of 0x0000FF, like I want).
Is there a way around this, or am I going to have to find a less direct
way?
Thanks. 1 1584 Ro*****@gmail.com wrote:
So I'm trying to read some data from a file, which includes hex
numbers of a known length (In my specific case, 6). I know there are
more indirect ways to do this, but I was hoping I could do it more
directly. For example, I want to read in the first 6 characters in
this string as a hex number:
0000FF123456
I was hoping I could do something along the lines of
int x;
ifstream file;
// Open the file, etc.
file >setw(6) >x;
The problem is, it ignores the 0s - x will have the value 0xFF1234
(Instead of 0x0000FF, like I want).
Is there a way around this, or am I going to have to find a less
direct way?
Use scanf. Unfortunately currently streams ignore the width setting
when in input mode.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: alanbe |
last post by:
Greetings
I am making a flashcard type application to help me in my TCP/IP
protocols test.
My instructor will test us periodically on how a device or networking
function relates to the OSI...
|
by: Eric Johnston |
last post by:
I want the visitor to enter three numbers on the page and then click a
button "generate image" which will I hope cause a generated gif image to be
displayed alongside on the page.
This involved...
|
by: dawenliu |
last post by:
Hi, I have a file with this content:
xxxxxxx xxxxxxxxxx xxxxx xxxxxxx
1
0
0
0
1
1
0
(many more 1's and 0's to follow)
|
by: ASiF |
last post by:
Hi i am completely novice at programming, would appreciate some help.
The program needs to be able to take a set of up to a 100 numbers (between
1 to 9) "inputted"
at the prompt and then assign...
|
by: Daniel Lidström |
last post by:
Hi,
how can I separate floating point numbers where I know their length, and
there is no whitespace between the numbers? The input looks something like
this:
35174844455445601605...
|
by: C G |
last post by:
Dear All,
I have a text file with data like:
1 2 3
4 5 6
7 8 9
i.e. so I have three columns of numbers.
I wish to put this data into a table. However, I do not want it to take up
three...
|
by: Sri |
last post by:
How do you add an n-bit number in C?
Regards,
Sri
|
by: Rick Knospler |
last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for
the most part except for the fixed length strings and fixed length string
arrays. Bascially the vb6 programmer stored all...
|
by: =?Utf-8?B?ZGg=?= |
last post by:
If there's bunch of hex numbers: 0xA6, 0xD9, 0x00, 0xAA, 0x00, and 0x62, how
to construct a string ("string" in C#) with those hex numbers?
Thanks!
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |