cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
how would i randomize a string
how would i randomize a string
May 8, 2011 at 3:07am UTC
pkee123
(3)
int junbleString (string str)
{
int length = str.length();
for(int i = 0; i < length; i++)
{
str[i] = str[rand() % (sizeof (str) - 1)];
}
}
i have this so far but im still stuck please help
May 8, 2011 at 3:18am UTC
prophetjohn
(70)
well, you can find the ascii table here:
http://bestofthisweb.com/blogs/wp-content/uploads/2009/11/ascii_table2.jpg
so, for each character in the string, generate a random number in the range according to which characters you want to include (eg: you want to use only lower case letters, generate a random number between 97 and 122 and assign it to str[i])
May 8, 2011 at 6:32am UTC
kfmfe04
(788)
this question seems to come up on a daily basis - maybe someone should write an Article on this
Topic archived. No new replies allowed.