Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define MAX_LENGTH 8
- int main(){
- unsigned int string_len;
- unsigned int iterations = 0;
- char *ran_string = (char *)malloc(MAX_LENGTH * sizeof(char)+1);
- int i;
- while(strcmp(ran_string, ":q!\n") != 0){
- iterations++;
- string_len = rand() % MAX_LENGTH;
- for (i = 0; i < string_len; ++i) {
- ran_string[i] = rand() % 127;
- }
- ran_string[++i] = '\0';
- }
- printf("Completed after %d iterations.", iterations);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement