Hi, I am trying to push short ints onto a char vector, with 4 digit padding (ie 1 becomes 0001 pushed on the vector )
This is what I have...but I keep on having these crazy f's appear all over the place and I don't know how to make it so they arent there...
Code:
vector<char> data;
// Note have some short int array pack length of pack_length
for ( int i = 0; i < pack_length; i++ ){
data.push_back ( ( pack[i] & 0xffff ) );
}
// Display results
for (int i = 0; i < data.size(); i < data.size(); i++ ) {
cout << hex << (int)data[i];
}
If I input the pack with a single value, 0xf9 then the output is
ffffffff8
However if the value is all digits then it works ok, like my test case of 45 gets pushed on just fine, but it is not padded with 0's.
Any help would be greatly appreciated. Thanks,
Prediluted