473,706 Members | 2,336 Online

How convert from vector to Byte array

6 New Member
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...

--------------------------------------------------------------------------------
Aug 25 '09 #1
13 11743
JosAH
11,448 Recognized Expert MVP
@dpsairam
Is your vector a Vector<Byte> or a Vector<Byte[]> or a Vector<byte[]>?

kind regards,

Jos
Aug 25 '09 #2
dpsairam
6 New Member
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
Aug 25 '09 #3
JosAH
11,448 Recognized Expert MVP
@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
Aug 25 '09 #4
dpsairam
6 New Member
my vector is Vector<byte[]>
Aug 25 '09 #5
r035198x
13,262 MVP
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?
Aug 25 '09 #6
dpsairam
6 New Member
@r035198x
what rules.......... ????dint get u
Aug 25 '09 #7
dpsairam
6 New Member
@r035198x
see i have a byte array in Vector i want to extract that byte array from this vector
Aug 25 '09 #8
r035198x
13,262 MVP
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
Expand|Select|Wrap|Line Numbers
1. int thePosition = 42;
2. byte[] theExtractedByteArray = (byte[])myVector.get(42);
3.
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?
Aug 25 '09 #9
JosAH
11,448 Recognized Expert MVP
@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
Aug 25 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

 2 2758 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 in a querystring, I can't figure out how to convert it back to a CipherMessage. 16 9202 by: Vince | last post by: Hi, I have replaced my BYTE* by a vector and before I used to do : void CCardRecord::GetRecData(int nOffset, int nDataSize, CString& csValue) { BYTE *pTmp = NULL; pTmp = new BYTE; memset(pTmp, 0, nDataSize + 1); //memcpy(pTmp, &m_pData, nDataSize); 16 16418 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 6 10213 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 the data converted from the byte array into a string , is not what i expect. example: - the data returned from the socket is (byte array) "Usuario Sin Atribuciones Para Esta FunciÃ³n" 3 10362 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, etc. I need: short = byte+byte, short = byte+byte, etc. 5 2277 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 the operations. The double value put in input should be muliplied with factor 1e10, in order to limit the loss of precision and divided with the same quantity in output. To make this, I've supposed to can modify the operator() for the access at... 7 3892 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 allocate multidimentional arrays like so: int *v_base = (int *) malloc(1000000*sizeof(int)); int **v = (int **) malloc(1000*sizeof(int *)); 2 12188 by: blueflyy | last post by: Hello, I wish to initialize a vector from an existing BYTE array. Simple example: BYTE buf = {0,1,2,3,4,5}; std::vector vec(buf, buf + sizeof(buf)/sizeof(buf)); 0 10771 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 inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret... 0 9286 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 9156 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... 1 9055 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,... 0 8997 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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some... 0 7911 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... 1 6615 by: isladogs | last post by: The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will... 0 5939 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 4709 by: adsilva | last post by: A Windows Forms form does not have the event Unload, like VB6. What one acts like? 1 3149 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

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.