Dear all,
I have used pointer in my program and I have a problem with shuffling
the values. The code is like:
..
..
..
for(i=0;i<S;++i)
{
k=i;
for (j=i+1;j<S;++j)
{
if (s[j].GN>s[k].GN) k=j;
}
Temp=s[i];
s[i]=s[k]; <<<<<<<<line that has error (as Valgrind says)
s[k]=Temp;
}
..
..
..
When I am checking the program with "Valgrind" it gives me the
following error message:
==25618== Source and destination overlap in memcpy(0x4A49BA8,
0x4A49BA8, 688)
==25618== at 0x4906C4A: memcpy (mac_replace_strmem.c:394)
==25618== by 0x4020E4: Shuffle(Record*, Record*) (109.cpp:885)
==25618== by 0x40DF21: main (109.cpp:229)
Does anyone have any idea how I can prevent this error?
Thanks,
Mohsen