Generate C code implementation for random passwords and c code

Source: Internet
Author: User

Generate C code implementation for random passwords and c code

Problem description

Some software often requires the user to enter a random password (or verification code) sent by the system during login to verify the user's identity and prevent malicious login.

A 6-digit random password string must be generated in C language.

 

Rand Functions

The rand function is a real random number generator. It returns a random value ranging from 0 to RAND_MAX (2147483647.

This function is prototype: int rand (void );

When using this function, you must include the header file "stdlib. h ".

 

C code implementation

Makefile content

TestRand: TestRand. c

Gcc-c-g TestRand. c

Gcc-g-o release/TestRandTestRand. o

Rm *. o

 

Random Password generation

After executing the "make" command, go to the "release" directory and run the "TestRand" command. The generated random password is as follows:

289383

930886

692777

636915

747793

238335

885386

760492

516649

641421

202362

490027

368690

520059

897763

513926

180540

383426

089172

455736

 

 

 

(My microblogging: http://weibo.com/zhouzxi? Topnav = 1 & wvr = 5, No.: 245924426, welcome !)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.