You are here:

C++/c program help


Writing a C program (call it RandPass.c) which can generate such passwords from 6 to 12 characters in length. The program should ask the user to enter the length of the password and then produce then produce the generated password.
sample:Password generating program

Enter the length of the password:   12

Your new password is:   Lq5wIo69XhkJ

1. write a function to generate a random printable character
        a. generate a random int in the range 0 - CHAR_MAX (use modulus operator)
        b. check if the char is printable: use the isprint function.
         if yes, return the char
         if no, repeat the above

2. in main, allocate a buffer to hold 13 chars
3. accept the length of the password from the user
4. in a loop, call the function to generate random printable characters
5. put a null character at the end of the generated chars.
6. print out the buffer as a (c style) string, and you are done


All Answers

Answers by Expert:

Ask Experts




my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.


about 15 years or so

post graduate engineer

©2016 All rights reserved.