05-12-2011, 09:10 PM
Want to add certain symbols inside my program in C++ how it will work see the code
using namespace std;
int main()
{
string line;
string total;
ifstream myfile ("tr.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
total = total + line;
}
myfile.close();
}
typedef boost::tokenizer< boost::char_separator<char> > tokenizer_type ;
const char* const dropped_delimiters = "',/!@#$%^&*()-_=+|]}[{:;'?/>.<,\\" ; // nothing
const char* const kept_delimiters = " \t" ; // space, tab
boost::char_separator<char> separator( dropped_delimiters, kept_delimiters ) ;
tokenizer_type toker( total, separator ) ;
int cnt = 0 ;
for( tokenizer_type::iterator beg = toker.begin() ; beg != toker.end(); ++beg )
std::cout << "token " << ++cnt << ": '" << *beg << "'\n";
}
using namespace std;
int main()
{
string line;
string total;
ifstream myfile ("tr.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
total = total + line;
}
myfile.close();
}
typedef boost::tokenizer< boost::char_separator<char> > tokenizer_type ;
const char* const dropped_delimiters = "',/!@#$%^&*()-_=+|]}[{:;'?/>.<,\\" ; // nothing
const char* const kept_delimiters = " \t" ; // space, tab
boost::char_separator<char> separator( dropped_delimiters, kept_delimiters ) ;
tokenizer_type toker( total, separator ) ;
int cnt = 0 ;
for( tokenizer_type::iterator beg = toker.begin() ; beg != toker.end(); ++beg )
std::cout << "token " << ++cnt << ": '" << *beg << "'\n";
}