Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ generate random char

char cch = 'a' + rand()%26;
Comment

C++ generate a random letter

#include <iostream>

int main() {
    srand(time(0));
    std::cout <<"random uppercase = " << char('A' + rand() % 26) << std::endl;
    // or
    std::cout <<"random uppercase = " << char('a' + rand() % 26) << std::endl;
}
Comment

getting a random letter in c++

    char c;
    int r;

    srand (time(NULL));    // initialize the random number generator
    for (i=0; i<num; i++)
    {    r = rand() % 26;   // generate a random number
          c = 'a' + r;            // Convert to a character from a-z
          cout << c;
    }
Comment

PREVIOUS NEXT
Code Example
Cpp :: unreal engine delay c++ 
Cpp :: shuffle vector c++ 
Cpp :: how to complie with c++ 17 
Cpp :: c++ lambda thread example 
Cpp :: c++ file is empty 
Cpp :: c++ print colorful 
Cpp :: torch cuda is available 
Cpp :: how to convert qt string to string 
Cpp :: const iterator c++ 
Cpp :: output coloured text in cpp 
Cpp :: for loop vector 
Cpp :: reverse sort cpp 
Cpp :: double max value c++ 
Cpp :: qt qlcdnumber change value 
Cpp :: exp() c++ 
Cpp :: qt qchar to lower 
Cpp :: how to interface c++ in haxe 
Cpp :: tostring c++ 
Cpp :: qt qmessagebox 
Cpp :: call of overloaded ‘swap(int&, int&)’ is ambiguous 
Cpp :: sort in descending order c++ stl 
Cpp :: qt qstring to double 
Cpp :: how to hide ui elements unity 
Cpp :: c++ loop pyramid 
Cpp :: easy c++ code 
Cpp :: tarray ue4 c++ 
Cpp :: find length of array c++ 
Cpp :: what is the short cut way to find the max and min element in an array in c++ 
Cpp :: how to compare lower case character to uppercase cpp 
Cpp :: how to add colored text in c++ 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =