I think I could solve this using a for loop. However I would need to know how to empty and resize a character array. Here is a quick sketch of what I was thinking of doing...
Code:
//Sends a string of data
void SockWrap::sSend(char* data){
//Initialise variables
int bytes_sent = 0;
int total = 0;
char temp = *data;
int i, x;
//Get length of data in bytes..
int len = sizeof(data);
//Loop until all data has been sent..
while (total < len) {
//Send data...
//If statement checks for errors. -1 is returned by send() if error occurs..
if ((bytes_sent=send(this->sockfd, &temp, sizeof(temp), 0)) == -1){
std::cout << "Error sending data!" << std::endl;
system("PAUSE");
exit(1);
}
total += bytes_sent;
//Empty temp array..
empty(temp); //????
//Reset x..
x = 0;
//Fill temp with remaining data...
for (i = total; i < sizeof(dat)-bytes_sent; i++) {
temp[x] = *dat[i];
x++;
}
}
}
However I dont know what should be in place of empty(temp) and the compiler doesnt like the line..
Code:
temp[x] = *data[i];
To which it replies..
Code:
85 C:\xmlgbx\gbx\socketwrap.cpp invalid types `char[int]' for array subscript
Any ideas?