dimanche 3 février 2019

Randomize what string to print in c

I got a quick question. Is it possible to 'randomize' the output I get? For example in the first run I get 'Magic number 1', and when I run it again, I could get 'Magic number 3'. I couldn't find any help elsewhere.

#include <stdio.h>

int main() {
char *a = "Magic number 1\n";
char *b = "Magic number 2\n";
char *c = "Magic number 3\n";

printf("%s", b);

    return 0;
}

I tried to edit the code to

printf("%s", a||b);

But || is used only to logic, right?




Aucun commentaire:

Enregistrer un commentaire