D
Dave Townsend
Hi,
I have to read some memory data from a stream. This would be in the
following format, for example:
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07
that is i have 8 values on a line, separated by whitespace, except the last
line which might not have a full complement of data.
I am reading the line into a istreamstring object and then trying to read
off each data item.
char ch1
char ch2;
unsigned short val;
istr >> ch1;
// check that I got something...
istr >> ch2;
// check that I got something...
istr >> val;
Then I check that I've got the "0x" piece:
if ( ch1 != '0' || ch2 != 'x') return error.....
So, with all this functionality in the stream classes, isn't there a way to
specify a certain pattern in the data, that is, I want to "expect" '0x',
then an integer ?
I seem to remember that scanf could do something like that, that is scan two
characers, then an integer.
Any piece of code or places to look would be welcomed.
dave.
I have to read some memory data from a stream. This would be in the
following format, for example:
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07
that is i have 8 values on a line, separated by whitespace, except the last
line which might not have a full complement of data.
I am reading the line into a istreamstring object and then trying to read
off each data item.
char ch1
char ch2;
unsigned short val;
istr >> ch1;
// check that I got something...
istr >> ch2;
// check that I got something...
istr >> val;
Then I check that I've got the "0x" piece:
if ( ch1 != '0' || ch2 != 'x') return error.....
So, with all this functionality in the stream classes, isn't there a way to
specify a certain pattern in the data, that is, I want to "expect" '0x',
then an integer ?
I seem to remember that scanf could do something like that, that is scan two
characers, then an integer.
Any piece of code or places to look would be welcomed.
dave.