I know about using ran() to create a random number between x and y, however i am creating a banking program and i am wondering how to randomly generate a 17 digit pin, then store the pin in an outside file, then have the program check the file for the pin
Superfat 0
Newbie Poster
Recommended Answers
Jump to Post#include <cstdlib> #include <string> inline char random_digit() { return '0' + std::rand() % 10 ; } inline std::string random_pin( std::size_t ndigits ) { std::string pin ; for( std::size_t i = 0 ; i < ndigits ; ++i ) pin += random_digit() ; return pin ; }
Jump to PostElaborate please =], i was trying to say that a-r are random numbers between 1 and 9, this is just a snipet of some code i already have, i an just having some problems with figuring out random numbers... i figured that if the largest variable is an unsigned, max …
All 8 Replies
vijayan121 1,152
Posting Virtuoso
Superfat 0
Newbie Poster
Jishnu 160
Posting Pro
mitrmkar 1,056
Posting Virtuoso
Superfat 0
Newbie Poster
iamthwee
Superfat 0
Newbie Poster
tesuji 135
Master Poster
iamthwee
commented:
Aw shucks, I'm not really God, it's just that's what the girls scream when they're with me. +14
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.