|
| |||||||||
| Tags: buffer, cpp, network driver |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| Place a uint > 255 in a buffer
I am currently working on frames by developing a network driver, so I follow hexa placed in buffers. I would add the size of my package to the frame in my buffer, here's how I proceeded: Code: UINT size = 4512, // I put a fixed value for my test memset (pDest, size, sizeof (size)) // I send this value in my buffer pDest //then after I send the frame ... how do I get for example: 00 00 11 a0 ff ff ff ff ff ff 45 ... I am not very clear, I hope you see my problem, thank you. |
|
#2
| ||||
| ||||
| Re: Place a uint > 255 in a buffer
The memset () that you give the data value (unsigned char) size with sizeof (size) of characters beginning in pDest table. If you want your chars have different values Code: pDest [3] = size % 256; pDest [2] = (size/256) % 256; pDest [1] = (size/256/256) % 256; pDest [0] = (size/256/256/256) % 256; |
|
#3
| ||||
| ||||
| Re: Place a uint > 255 in a buffer
char * pdest = gnigni * ((UINT *) pdest) = size; pdest + = sizeof UINT; by effectively against the endianness depends cpu, so if you want big endian, you fall on the solution Programmer (but with >> and & in principle, or just a >>) |
|
#4
| ||||
| ||||
| Re: Place a uint > 255 in a buffer
pDest is PUCHAR type, yes. As against it can not go through having to choose the character of the table? pDest [0], pDest [1 ],... I feel that is what the method of Ashok.M offers but I do not understand how it works? |
|
#5
| ||||
| ||||
| Re: Place a uint > 255 in a buffer
When I write C++, I do not write assembler. When I write the assembler, not I do not write C++. I think this operation has a decomposition as in base 256, so I expressed it as: Code: size = ((p[0]* 256 + p[1])*256 + p[2])*256 + p[3]; |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Place a uint > 255 in a buffer" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Setting depth buffer (z buffer) size (16bit / 24bit) | NewComer | Monitor & Video Cards | 4 | 08-04-2010 06:47 AM |
| How can i convert c# 'uint' to 'int' | Taipai | Software Development | 3 | 02-06-2009 06:20 AM |
| Buffer of a disk | Xan | Hardware Peripherals | 3 | 16-03-2009 10:41 AM |
| I'm having trouble with the buffer | monsitj | Technology & Internet | 4 | 22-09-2008 08:50 PM |
| Putting a certificate in the proper place after accidentally puttingit in the wrong place | Morris Cox | Vista Help | 5 | 05-09-2007 12:16 AM |