[bbone=cpp,499]# include
include
include
include
include
using namespace std;
int main(int argc, char const *argv[])
{
uint8_t buffer[65536];
int read_size = SSIZE_MAX, bytes_read = 0;
//int bytes_read = read (0, buffer, sizeof(buffer));
//cout << "Can Read MAX of " << read_size << " Bytes" << endl;
string str = "";
while ((bytes_read = fread (buffer, 1, 32767, stdin)) > 0) //This works
//while ((bytes_read = fread (buffer, 1, 65535, stdin)) > 0) //This fails to read
//while ((bytes_read = fread (buffer, 1, 32768, stdin)) > 0) //This too fails
{
cout << "Successfully Read " << bytes_read << " Bytes" << endl;
fwrite (buffer, 1, bytes_read, stdout);
}
//cout << "Successfully Read " << bytes_read << " Bytes" << endl;
return 0;
}
[/bbone]
I am trying to read data faster with read and fread. They both fail to read data from my console window when I specify any value greater than 32767 for the buffer size parameter. Don't know why
How do I find the maximum possible value for that parameter? Can anybody help me with this? I searched internet for two hours but found no solution or explanation to this.