Hello,
In a
stack<std::string>
I am doing a push() operation and stack contains data as below
[0]"-0585,-2857,-0059,00359,00360,00360,00100,02000,-0030,00360,00360,00360,00360,00360,00360,A%"
[1]"-0457,-2004,-0059,00359,00360,00360,00100,02000,-0030,00360,00360,00360,00360,00360,00360,B%"
[2]"-0477,-0358,-0059,00359,00360,00360,00100,02000,-0030,00360,00360,00360,00360,00360,00360,C%"
[3]"-0128,-1538,-0059,00359,00360,00360,00100,02000,-0030,00360,00360,00360,00360,00360,00360,D%"
[4]"-0155,-0378,-0059,00359,00360,00360,00100,02000,-0030,00360,00360,00360,00360,00360,00360,E%"
and so on 10000+.
Simultaneously I'm also performing a top() operation, which should return
"-0155,-0378,-0059,00359,00360,00360,00100,02000,-0030,00360,00360,00360,00360,00360,00360,E%"
but it returns the following as string format
"-1.#IND,-1.#IND,-1.#IND,00359,00360,00360,00100,02000,-0030,00360,00360,00360,00360,00360,00360,E%"
Moreover if i do check using
stack.top().size() != 0
,the top value changes and returns -1.#IND.....so on.
Why is the first 15 elements(excluding the ',') is changing to this nan values in a string?
//improved
I am using a boost client-server architecture(simple chat example).
Client1 ---posts data--> Server --publish data --> Client2(reads data in stack).
Client1 reads data from a COM port and posts the data.
Client2 pushes the received data to the stack.
The stack contents remains okay. But whenever i use the following code problem appears
boost::shared_lock<boost::shared_mutex> lock(_access);
std::string mStr = "";
if(!stackstring.empty() && stackstring.top().size() != 0)
{
mStr = stackstring.top();
stackstring.pop();
}
only the top value gets corrupted with -1.#IND..
so mStr gets wrong values. boost locks are used as read/write operation occurs simultaneously on the same stack variable.
Any help regarding this problem is appreciated.
Thanks and Regards,
Sayan.