Skip to content

Instantly share code, notes, and snippets.

@john302
Created October 3, 2018 01:03
Show Gist options
  • Save john302/66d8f7a221b0535aed798e3f80d4801b to your computer and use it in GitHub Desktop.
Save john302/66d8f7a221b0535aed798e3f80d4801b to your computer and use it in GitHub Desktop.
Program to print a random string.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main (void) {
srand((unsigned int)(time(NULL)));
int index = 0;
char char1[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/,.-+=~`<>:";
for(index = 0; index < 48; index++)
{
printf("%c", char1[rand() % (sizeof char1 - 1)]);
}
puts("");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment