I am using a pipe with an external software in a c++ program.
The method to send a given command through the pipe takes as argument:
- a char* containing the command to send,
- a second char* where to copy the output coming from the command that has just been sent, and
- the size of this latter parameter.
under the form: SendCommand(line, line, sizeof(line));
For one of my commands, the output coming from the pipe (2nd parameter) features 5 or 6 pages of characters, that is why I'd like to know if someone would know how to store all of that in a variable of type char* (that I copy to an external .txt file afterward).
I would not use the same buffer for input/output unless the SendCommand function specifically says that's OK in the documentation. Otherwise, when SendCommand writes to the output buffer, it will wipe its input.
Note I pass "report species" directly, rather than sticking it 'line'.
Anyway, to store a larger number of characters, just make your buffer larger:
1 2 3
int size = 100000; /* or however big you need it */
char* line = newchar[size];
SendCommand( "whatever", line, size ); // note that we can no longer use sizeof() here
That seems to work, thank you very much.
Though, I notice that there is a size limit of 276447231.
(When I enter int size = 276447232 and display the size after have used my pointer the way I wanted, I notice its size has been decreased to 276447231...)