When vector "data" is initialized it is 520 chars long and they are all set to zero. When you try to initialize string "tmp" from data.data(), the constructor will just see an empty string (first byte is zero) so it creates an empty string. Then you look for your substring in tmp, which is empty. That substr call will crash. You should presumably look in the string testValue for the substring.
It is very strange to pass sizeof(char) (i.e., 1) as the third parameter to memccpy. The third parameter is supposed to be the character to stop at.
It looks like there may be some logic errors, too. What exactly is this code supposed to do?
my code take 24 and fill in buffer , then return 0 when my buffer is full.
thank'ss!!!!!!
Not even close.
Line 22: tmp is a string filled with 0. So you have a string with 4 0's.
Line 28: This will certainly throw an exception.
Line 32: I have no idea what this is supposed to do.
sizeof(char) is wrong there. i_str4? Your intention was the value 24. But how does it make sense?
The loop goes until dt but since you add 4 to rt it will go out of bounds soon... (i.e. crash)
The third paramenter (where you currently put sizeof(char)) must be a character (like 'A') which determines where to stop copying
The fourth parameter determines the maximal length to copy.
With the code you posted it is impossible to produce such an output.
@Thomas I would like to make a code which got a data eg : "##############__HEADER__\nprotocol:1\ncontent-length:24\n\n"
My code has to take the value of the content-length which is 24 and stores him in the buffer in this first case and after when we enter a new value ("##############__HEADER__\nprotocol:1\ncontent-length:30\n\n") it recupures still the content-length which will be 30 and this stores him in the buffer following 24 if 24 set place 0 1 then 30 will take 2 3. one time the full buffer it sends back I am full and we can nothing more store.
The linker doesn't output things because it thinks your screen looks prettier with lots of text. It outputs things because those things are useful information in helping to fix the problem. So pass that help onto us.
are you messing up memcpy? Your use of it seems questionable at best, but generally I take it that anyone using that function is an expert and knows what they are doing. Memcpy and classes don't mix well, you have to be very careful, and that includes built in classes like vector/string/etc.
consider replacing it with a dumb copy loop to debug, and if that solves the problem, revisit your use of memcpy to see what you did wrong or if you shouldn't even be using it.
@Thomas1965
The purpose of the program is to provide to feign a parser. I request a tram of data, I recuperate its data (where from the size 24) then I store this value in my buffer, then a new data arrives, I copy in the buffer the size and so on until my buffer is full and my program sends back full memory.