I
ishmael4
hello!
i've go two structures:
--cut here--
const unsigned int max_pkg_data=5000;
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(binary& sent)
{
unsigned int n=0;
for (n=0;n<sent.size/max_pkg_data;++n)
{
pkg nPkg;
memcpy((void*)nPkg.data,(void*)sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=0;
nPkg.size=max_pkg_data;
// tu wpisujesz swoj kod do obs³ugi binary
Form1->CC1->Socket->SendBuf((void*)&nPkg,sizeof(pkg));
}
pkg nPkg;
memcpy((void*)nPkg.data,(void*)sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=0;
nPkg.size=sent.size-((n)*max_pkg_data);
Form1->CC1->Socket->SendBuf((void*)&nPkg,sizeof(pkg));
return;
}
--cut here--
Especcialy:
memcpy((void*)nPkg.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?
i've go two structures:
--cut here--
const unsigned int max_pkg_data=5000;
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(binary& sent)
{
unsigned int n=0;
for (n=0;n<sent.size/max_pkg_data;++n)
{
pkg nPkg;
memcpy((void*)nPkg.data,(void*)sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=0;
nPkg.size=max_pkg_data;
// tu wpisujesz swoj kod do obs³ugi binary
Form1->CC1->Socket->SendBuf((void*)&nPkg,sizeof(pkg));
}
pkg nPkg;
memcpy((void*)nPkg.data,(void*)sent.buffer[n*max_pkg_data],max_pkg_data);
nPkg.info=0;
nPkg.size=sent.size-((n)*max_pkg_data);
Form1->CC1->Socket->SendBuf((void*)&nPkg,sizeof(pkg));
return;
}
--cut here--
Especcialy:
memcpy((void*)nPkg.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?