c++ - Blinking cursor on console during cout string -


when console opens , program runs blinking cursor. there doing wrong? program running fast me see it?

thank in advance.

#include <iostream> #include <iomanip> #include <string> #include <cstring> #include <ctime>  using namespace std;  string randomstring(int len) {     srand(time(0));     string str = "01213456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";     int pos;     while (str.size() != len) {         pos = ((rand() % (str.size() - 1)));     }      return str; }  int main() {     string random_str = randomstring(10);     cout << "random_str : " << random_str << endl;     system("pause");     return 0; } 

it looks while loop never exits:

    while (str.size() != len) {         pos = ((rand() % (str.size() - 1)));     } 

you update pos in loop, don't use pos in while condition.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -