So I've implemented the Longest Common Subsequence algorithm for the Introduction to Algorithms book (CLRS) in C++, and it works fine, kinda. When I do something like this:
./lcs abc bc > OUTPUT
When I open the OUTPUT
file in vim
, I see this:
2 bc^@
Which is correct, sans that weird ^@
symbol. I did some Googling and this appears to be some sort of NULL
character?
I've never run into this problem before.. anyone know how to get rid of it?
Thanks! -kstruct
EDIT Here's the code that does the printing:
cout << lcsLength << " ";
if (lcsLength > 0) cout << lcsString;
return 0;
Where lcsString
is a std::string
. Not sure if that helps...