Markov chain text generator: Difference between revisions

→‎{{header|C++}}: unused TextPos variable and pos variable in createText() removed, using std::string::npos instead of -1 (size_t is never negative!), made keyLen, words and kl unsigned
(→‎{{header|Rust}}: add 2018 edition requirement)
(→‎{{header|C++}}: unused TextPos variable and pos variable in createText() removed, using std::string::npos instead of -1 (size_t is never negative!), made keyLen, words and kl unsigned)
Line 64:
class markov {
public:
void create( std::string& file, unsigned int keyLen, unsigned int words ) {
std::ifstream f( file.c_str(), std::ios_base::in );
fileBuffer = std::string( ( std::istreambuf_iterator<char>( f ) ), std::istreambuf_iterator<char>() );
Line 93:
std::cout << "\n";
}
void createDictionary( unsigned int kl ) {
std::string w1, key;
size_t wc = 0, pos, textPos, next;
next = fileBuffer.find_first_not_of( 32, 0 );
if( next == -1std::string::npos ) return;
while( wc < kl ) {
pos = fileBuffer.find_first_of( ' ', next );
Line 146:
tin arms and
</pre>
 
 
=={{header|C#|C sharp}}==
3

edits