Hi,
How to convert a Vector to a Byte array....i have vector which contains a Byte array.....i need to convert the vector into Byte array...
--------------------------------------------------------------------------------
13 11647 @dpsairam
Is your vector a Vector<Byte> or a Vector<Byte[]> or a Vector<byte[]>?
kind regards,
Jos
Is your vector a Vector<Byte> or a Vector<Byte[]> or a Vector<byte[]>?
can you tell me what is the difference between these three
@dpsairam
A Vector<Byte> contains objects of type Byte; a Vector<Byte[]> contains arrays and each element is a Byte type object. A Vector<byte[]> contains arrays of bytes; they are of primitive type.
kind regards,
Jos
my vector is Vector<byte[]>
So you have a lot of these byte arrays (byte[]) in a Vector. And you want to 'convert' them to just one byte[]? What are the rules for the conversion?
@r035198x
see i have a byte array in Vector i want to extract that byte array from this vector
Is there only one byte[] in the Vector then?
That simplifies matters somewhat.
Now all you need is to know what position in the Vector the array is at. Suppose the array is at index 41, then you simply do the simple -
int thePosition = 42;
-
byte[] theExtractedByteArray = (byte[])myVector.get(42);
-
1.) If you use generics you won't need the cast.
2.) Why do you have Vector if you only have one byte[] to store?
3.) Why did you use Vector instead of ArrayList?
@dpsairam
Suppose you have three arrays in the Vector with the following elements:
a1, a2 b1, b2, b3 and c1, c2
How do you want to store those seven elements in one array? There are several options and you know the 'rules', not us because we're not psychic.
kind regards,
Jos
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
Silly fingers, that should teach them to type of their own accord.
@r035198x
I never have that.
kill regexp
Java ;-)
@OP: I wonder how you got that byte[] in your Vector if you don't know how to get that element out of it.
kind regards,
Jos
ps. I noticed you reporting this thread; better concentrate on being clear so that we can answer your extremely vague question instead.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nathan |
last post by:
Is there a way to convert a string to a CipherMessage? I am calling a
function that decrypts a CipherMessage and returns the value. The only
problem is when I want to use an encrypted value stored...
|
by: Vince |
last post by:
Hi,
I have replaced my BYTE* by a vector<BYTE> and before I used to do :
void CCardRecord::GetRecData(int nOffset, int nDataSize, CString& csValue)
{
BYTE *pTmp = NULL;
pTmp = new BYTE;...
|
by: Khuong Dinh Pham |
last post by:
I have the contents of an image of type std::string. How can I make a
CxImage object with this type.
The parameters to CxImage is:
CxImage(byte* data, DWORD size)
Thx in advance
|
by: Ricardo Quintanilla |
last post by:
i have a code that sends data to a socket listening over as400 platform,
the socket responds to me as a "byte array".
then i need to convert the "byte array" into a string.
the problem is that...
|
by: MuZZy |
last post by:
Hi,
I just wonder if someone can help me wit this -
i have a byte array and need to convert it to short array, creating
short numbers by combining bytes by pairs:
My array: byte, byte, byte,...
|
by: Toto |
last post by:
Hello,
I've got a problem with the redefinition of operator in C++. My intent
is to create a TVector that internally work with __int64, with an
external interface of double in order to optimize...
|
by: nw |
last post by:
Hi,
We've been having a discussion at work and I'm wondering if anyone
here would care to offer an opinion or alternative solution. Aparently
in the C programming HPC community it is common to...
|
by: blueflyy |
last post by:
Hello,
I wish to initialize a vector<BYTE> from an existing BYTE array.
Simple example:
BYTE buf = {0,1,2,3,4,5};
std::vector<BYTE> vec(buf, buf + sizeof(buf)/sizeof(buf));
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
| |