application crash

Hi,

When I am using memcpy my application getting crashed I have used memcpy like below

char *data; //it has some data content
int dataLenth = some_length;
BYTE* data_ptr = new BYTE[SOME_LENGTH];
memcpy(data_ptr, &data[0], dataLength);

Please help on this.

Thank You,
dataLenth is not the same as dataLength.
some_length is not the same as SOME_LENGTH.

what variable declarations/initialisations arent you showing us?
Hi Sorry guys please check this to avoid confusions and I am expecting the reasons why it is crashing while using memcpy.

char *data = Buffer(it has some data defined not only declaration); //it has some data content
int dataLenth = LenghtOData(the data has been defined and declared above);
BYTE* data_ptr = new BYTE[SOME_LENGTH]; //SOME_LENGTH is cont in value
memcpy(data_ptr, &data[0], dataLength);

here dataLength and lengthOfData are same consider that..
here dataLength and lengthOfData are same consider that..

No, lengthOfData does not exist, dataLenth and LenghtOData have the same value, according to your last post.
Your code works only if SOME_LENGTH = dataLenth = LenghtOData = dataLength...
Too many variables for a single value!!!
Topic archived. No new replies allowed.