Re: Problem with VS and memcpy...
- From: "Alexander Grigoriev" <alegr@xxxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 08:41:09 -0700
Do you really have to use intermediate header[8], rather than set the bytes
directly in buffer?
"Paolo" <paomic@xxxxxxxxx> wrote in message
news:1151575114.297220.27410@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The excat code is:
int number = 25;
int offSet = 16000;
unsigned char header[8];
header[0] = 0;
header[1] = 255;
header[2] = 0;
header[3] = number>>8;
header[4] = number;
header[5] = offSet>>16;
header[6] = offSet>>8;
header[7] = offSet;
memcpy(buffer, header, sizeof header);
John Carson ha scritto:
"Paolo" <paomic@xxxxxxxxx> wrote in message
news:1151573245.812709.93530@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Yes I amde some mistakes in the code, I couldn't paste because it was
too long.
Yes, the correct lines are
unsigned char* buffer = new unsigned char[1000];
and
memcpy(buf, temp, sizeof temp);
I didn't use the redundant casts at first, but then I added them, but
nothing changed.
The problem isI just can't see why if I use the debugger before the
memcpy I can see something like
buffer = 0x01234456 "yqhsfjkvdfdsfhfe"
Where "yqhsfjkvdfdsfhfe" ius the content of the buffer, but after
thememcpy it becomes
buffer = 0x01234456 ""
Is it normal?
The content of buffer will only be displayed up until the first
terminating
zero. It looks to me like temp has a terminating zero (i.e., '\0') as its
first character.
You need to give us code that actually exhibits the problem (and no other
problem). Code that looks like your code but doesn't have the problem is
useless.
--
John Carson
.
- References:
- Problem with VS and memcpy...
- From: Paolo
- Re: Problem with VS and memcpy...
- From: Tom Widmer [VC++ MVP]
- Re: Problem with VS and memcpy...
- From: Paolo
- Re: Problem with VS and memcpy...
- From: John Carson
- Re: Problem with VS and memcpy...
- From: Paolo
- Problem with VS and memcpy...
- Prev by Date: Trouble getting file owner on large amount of files
- Next by Date: first-chance exceptions (& suppressing them in the debug window)
- Previous by thread: Re: Problem with VS and memcpy...
- Next by thread: Re: Problem with VS and memcpy...
- Index(es):
Relevant Pages
|
Loading