Re: Problem with VS and memcpy...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"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


.



Relevant Pages

  • Re: Unplanned Obsolescence
    ... > Other factors to consider are whether the software is capturing to a ... > "local" temp drive first, or to memory, and what kind of buffering there ... The Onyx has a choice of several latency (buffer size) settings. ...
    (rec.audio.pro)
  • Re: malloc()/realloc() - have I got this right?
    ... Be aware, if you do so, that the above routine has what some people ... int cursize, ch, ix; ... char *buffer, *temp; ...
    (comp.lang.c)
  • Re: input word
    ... int cursize, ch, ix; ... char *buffer, *temp; ...
    (comp.lang.c)
  • Re: Storing input into a character array
    ... you're not protecting your buffer against ... fields you want to parse). ... you're using &temp rather than temp - ... use fgets rather than fscanf. ...
    (comp.lang.c)
  • Re: Vi and stdout
    ... I am not satisfied by!!command to a temp file and use multi file editing, I want vi to hook into stdout directly or somehow redirect stdout to some temp buffer in vi, the temp buffer should not be my file buffer i am editing. ... I've discovered another, less risky, way to create a "scratch" buffer for capturing program output: ...
    (comp.os.linux.misc)