C++ String reaches over several NUL Bytes -


I hate to ask this because I think it should be very trivial. But this is a real problem as a person who is used as a high level language.

I got a C ++ program, which uses PDF to create an image for a PDF. And I have a C # program that communicates with the C ++ program through designated pipes, the PDF file (which is saved as a byte-array) gets transmitted by the pipe. And here's my problem.

In the 374th of the stream, there is a NUL byte (00) and in any way I am very stupid to access the data.

Here is my code:

  LPTTRS LPPPNname 2 = TXT ("\\\\. \\ pipe \\ myNamedPipe2"); HPipe2 = Create file (LPPPNName2, GENERIC_READ, 0, ZERO, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); If (Readfile (HPP2, Chabuff, Dvibet's Tyride, and CB Read, Faucet)) {PDF Data = CFF; }   

The dwBytes file is size for reading and cbRead shows the correct number. But only the first 373 bytes included in PDF data. I checked that the figure beyond the 373th position is immediately with the window, I do not know how to process it. I have to put the data into four-arrays.

As I said earlier, I think that this is very trivial. But although I know where the problem comes from, I do not know how to fix it.

Many thanks and Regards

Michael

EDIT: C # -Code. Everything is perfect, but I am pretty sure this problem is on C ++ side.

  Public Zero SendRawData (byte [] data) {while (clientse == faucet || clientse.stream == faucet} {} if (clientse.stream.CanWrite) {clientse.stream. Write (Data, 0, Data. Lang); Clientse.stream.flush (); }} Private Wide Sonoforaculants () {While (True) {ClientHandle = ContemporaryIPipip (This Popename, Duplex | FILE_FLAG_OVERLAPPED, 0, 255, BFFSIS, Buffecs, 0, Int.T.Zorro); // Can not create named pipes if return (clientHandle.IsInvalid); Int success = Connectim pipe (Clienthandle, int. Zorro); // Client can not connect if return (success == 0); Clientse = new customer (); Clientse.handle = CustomerHandle; Clientse.stream = New filestream (Client.Handle, File Access; RedVrite, Bugfasia, True); If (client type == 0) {threadreadtread = new thread (new threadstart (read)); ReadThread.Start (); }}}   

"solution": In fact, this was never a real problem. I just crossed my strings when I was chrish after copying it in PBData or when I read its value, it is only 373 bytes. All ~ 20 kilobytes were copied in that position. I knew that, but I did not know how to know the pdfium sources that if the string ends after 373 characters.

Well ... pdfium-sources know that i have to cross its length which was determined

  size_t len ​​= PDFData.length ();   

And so of course there are only 373 bytes.

zero characters '\ 0' to char * string is used by C / C ++, then any library function (i.e. strlen () , strncpy () , etc. ) will use zero characters as an endless string indicator. Your code is obviously doing it elsewhere. Div>

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -