How to generate X random ASCII characters of length X each in C

1 Answer

0 votes
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h> 

int main(void) {
    srand((unsigned int) time(NULL) + getpid());

	int X = 10, N = 5;
	while (N--) {
		int tmp = X;
		while (tmp--) {
			putchar(rand() %  (126 - 33 + 1) + 33);
			srand(rand());
		}
		printf("\n");
		tmp = X;
	}

	return 0;
}
 
 
 
/*
run :
 
8R#a(V[6Ws
qBsjV((J<V
FJkd#wg2<}
aKaFAq>jd,
uH`XMm)@1G
 
*/

 



answered Feb 13, 2021 by avibootz

Related questions

1 answer 158 views
1 answer 199 views
1 answer 132 views
1 answer 121 views
1 answer 119 views
1 answer 92 views
...