Hi All!
I'm having a problem passing strings into a boost tokenizer. I have been able to get the code to work but I don't think I should have had to do what I did. I don't know if it is tokenizer problem or a compiler problem or my problem.
Basically, I start with a char[] and depending on how I convert it to an std::string, I may or may not get garbage tokens.
I've attached a complete, but small, program to demonstrate the problem. I hope someone can tell what is going on.
I'm using a Fedora 8 system with g++ v 4.1.2.
Thanks in advance!
Medora
#include <iostream>
#include <string>
#include
AMDG Medora Schauer wrote:
I'm having a problem passing strings into a boost tokenizer. I have been able to get the code to work but I don't think I should have had to do what I did. I don't know if it is tokenizer problem or a compiler problem or my problem.
// This version results in garbage in some tokens. char **str = in_strs; while (*str){ str_tokenizer file1_tokens(string(*str), sep); // <-- difference
tokenizer stores the string by reference. The temporary string is destroyed. Boom. In Christ, Steven Watanabe
Ah! I wasn't even considering where the string was getting created. It's on the call stack I guess? Thanks!
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: Thursday, March 12, 2009 11:56 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] tokenizer problem
AMDG
Medora Schauer wrote:
I'm having a problem passing strings into a boost tokenizer. I have been able to get the code to work but I don't think I should have had to do what I did. I don't know if it is tokenizer problem or a compiler problem or my problem.
// This version results in garbage in some tokens. char **str = in_strs; while (*str){ str_tokenizer file1_tokens(string(*str), sep); // <-- difference
tokenizer stores the string by reference. The temporary string is destroyed. Boom.
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Medora Schauer
-
Steven Watanabe