[Dev] dev mystery solved
Michael Mueller / Signalnetware
dev@trilug.org
Tue, 7 May 2002 17:07:59 -0400
I killed everyone of my filters (waaaaaa)...then I remembered what the
problem is (grrrrr). Yahoo kill pop access to mail. I ditched them. I am
subscribed to dev as bhu5nji@yahoo.com. I'm going in now to make changes.
My app transforms a 10 digit telephone number as follows: comes in via TCP as
a sequence of ASCII char; gets transformed and saved into a PACKED array of
nibbles (unsigned int bcd_digit:4 PACKED;) containing BCD values (digit -
'0'), the BCD array gets transformed into a string so the telephone number
becomes a key into a map. The map is duplicated on two mated machines, so
the string key is decomposed into ASCII chars and put into a intermachine
comm structure payload section (plain old byte array). On the other side,
this char string is reassmbled into the map key string.
At the end of this juggling act I should be able to use the same telephone
number to get the same map entry on both machines. That is not the case.
One map's key is len==11 "2128902345"+'\0' and the other is len==10
"2128902345".
The problem was solved by removing the line that adds '\0' to the string. I
was getting caught up in the internal representation of the string as though
it were an array of chars needing a null terminator. The twist came from the
results as Ed pointed out:
a not equals b (this is the comparison the map container is using)
a.c_str() equals b.c_str()
If you try to printf or cout the strings, there are no visual clues
--
Michael Mueller
Signalnetware, Inc.
www.signalnetware.com
919.621.6090