I am trying to read a large binary file thought input redirection (stdin) at runtime, and stdin is mandatory.
./a.out < input.bin
So far I have used fgets. But fgets skips blanks and newline. I want to include both. My currentBuffersize could dynamically vary.
FILE * inputFileStream = stdin;
int currentPos = INIT_BUFFER_SIZE;
int currentBufferSize = 24; // opt
unsigned short int count = 0; // As Max number of packets 30,000/65,536
while (!feof(inputFileStream)) {
char buf[INIT_BUFFER_SIZE]; // size of byte
fgets(buf, sizeof(buf), inputFileStream);
cout<<buf;
cout<<endl;
}
Thanks in advance.
freadis for unprocessed input.fgetsas you say does text processing. Don't ignore the return value which is the number of valid records stored to the buffer.cin, so it's not really related to this question, and secondly, the answer there actually tells you how to do it. This question was just a failure to read documentation for stdio / a failure to search Google for "read binary data from stdin".