string - How to create a file with random char in C? -


i have no problem in generate random numbers rand() have create output file string of char e.g. "aqsdjeiofhduk" when result of rand ()%26 +1 1 i've print in file "a" when result "2" b , on. know priori how many char in string let's 50. i've in c language. function should use? strcat?

simple set array random letters selected via rand()

#define random_string_length 50  char buf[random_string_length + 1]; (size_t = 0; < random_string_length; i++) {   buf[i] = "abcdefghijklmnopqrstuvwxyz"[rand() %26]; } buf[random_string_length] = '\0';  puts(buf); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -