hello!
i've go two structures:
--cut here--
const unsigned int max_pkg_data=50 00;
typedef struct pkg_ {
short int info;
short int size;
char data[max_pkg_data];
} pkg;
typedef struct binary_ {
char* buffer;
int size;
} binary;
--cut here--
and i cant understand, why isnt this function working:
--cut here--
void SendBinary(bina ry& sent)
{
unsigned int n=0;
for (n=0;n<sent.siz e/max_pkg_data;++ n)
{
pkg nPkg;
memcpy((void*)n Pkg.data,(void* )sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=0;
nPkg.size=max_p kg_data;
// tu wpisujesz swoj kod do obs³ugi binary
Form1->CC1->Socket->SendBuf((void* )&nPkg,sizeof(p kg));
}
pkg nPkg;
memcpy((void*)n Pkg.data,(void* )sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=0;
nPkg.size=sent. size-((n)*max_pkg_da ta);
Form1->CC1->Socket->SendBuf((void* )&nPkg,sizeof(p kg));
return;
}
--cut here--
Especcialy:
memcpy((void*)n Pkg.data,(void* )sent.buffer[n*max_pkg_data],max_pkg_data);
Gives me an Acces Violation Message? Why is it so? Anyone could help me?
--
ishmael4
i've go two structures:
--cut here--
const unsigned int max_pkg_data=50 00;
typedef struct pkg_ {
short int info;
short int size;
char data[max_pkg_data];
} pkg;
typedef struct binary_ {
char* buffer;
int size;
} binary;
--cut here--
and i cant understand, why isnt this function working:
--cut here--
void SendBinary(bina ry& sent)
{
unsigned int n=0;
for (n=0;n<sent.siz e/max_pkg_data;++ n)
{
pkg nPkg;
memcpy((void*)n Pkg.data,(void* )sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=0;
nPkg.size=max_p kg_data;
// tu wpisujesz swoj kod do obs³ugi binary
Form1->CC1->Socket->SendBuf((void* )&nPkg,sizeof(p kg));
}
pkg nPkg;
memcpy((void*)n Pkg.data,(void* )sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=0;
nPkg.size=sent. size-((n)*max_pkg_da ta);
Form1->CC1->Socket->SendBuf((void* )&nPkg,sizeof(p kg));
return;
}
--cut here--
Especcialy:
memcpy((void*)n Pkg.data,(void* )sent.buffer[n*max_pkg_data],max_pkg_data);
Gives me an Acces Violation Message? Why is it so? Anyone could help me?
--
ishmael4
Comment