Error stack around the variable was corrupted

I have one problem with my code it's working until end of this program and program show this error: Run-Time check failure #2 - Stack around the variable 'Obsd" was corrupted. Thanks for fast help and here is a code, :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <conio.h>
using namespace std;
struct SData
{
	int SDSamples;
	float SDSampleCount;
};
struct SDats
{
	int SDSamples;
	float SDSampleCount;
};
void main()
{
	SData Obsd;
	SDats Obsds;
	Obsd.SDSampleCount = 15.2;
	Obsd.SDSamples = 15;
	
	char chObsd[100] = {0};
	char chObsds[100] = {0};
	memcpy( chObsd, &Obsd,  sizeof(Obsd));
	memcpy(chObsds, chObsd, 100);
	memcpy(&Obsds, chObsds, 100);
	cout <<"First: " << Obsds.SDSamples << endl;
	cout <<"Secound: " <<  Obsds.SDSampleCount<< endl;
	getch();
	

}
On line 25 you copy 100 bytes but Obsds is only sizeof(SDats) bytes.
Topic archived. No new replies allowed.