I wrote the following code from this.
#define MAX_XFER_BUF_SIZE 16384
int main()
{
char buffer[MAX_XFER_BUF_SIZE];
//..some content
access_type = O_RDONLY;
sftp_file file = sftp_open(sftp, "/home/ra/Desktop/sami/s.txt", access_type, 0);
ofstream fin("C:/Users/s.txt", ios::binary | ios::in | std::ofstream::out | std::ofstream::app);
nbytes = sftp_read(file, buffer, sizeof(buffer));
fin.write(buffer, sizeof(buffer));
But the buffer maximum size is predefined. So it only works for small files. I want to get the SFTP file size which size is much bigger. For that I need to send the data as chunks by append mode.
for (int i=0;i<sizeof(buffer);i++)
{
fin.write(buffer, buffer[i]);
}
I went through this answer, but i'm stuck in this > How can i solve this issue.