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

#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 ;
}

I tried it, and recieved an error,

[Linker error] undefined reference to `WinMain@16'

vijayan121 has just provided the functions, you'll have to adapt them according to your main code and use them. His functions will compile, but how do you expect them to run?!

I tried it, and recieved an error,

[Linker error] undefined reference to `WinMain@16'

You are trying to build a Win 32 GUI program and you have no WinMain(...) - hence the error.
If you want to build a GUI program, then write the WinMain(...) too, see
http://msdn.microsoft.com/en-us/library/ms633559.aspx

Otherwise, start a new Win32 Console Application project, which uses the int main() .

Okay, i tried something that i thought up, reading up i remembered that a 17 digit number isnt really possible in C++... so i have come up with this, however i am getting two errors, i think it has something to do with the brackets... but i cant figure anything out

#include <cstdio>
      #include <cstdlib>
      #include <ctime>
      #include <iostream>
      
      using namespace std;
      int main(int nNumberofArgs, char* pszArgs[])
   {  
     srand ( (unsigned)time ( 0 ) );
      
     const int a = rand() % 9 ;
     const int b = rand() % 9 ;
     const int c = rand() % 9 ;
     const int d = rand() % 9 ;
     const int e = rand() % 9 ;
     const int f = rand() % 9 ;
     const int g = rand() % 9 ;
     const int h = rand() % 9 ;
     const int i = rand() % 9 ;
     const int j = rand() % 9 ;
     const int k = rand() % 9 ;
     const int l = rand() % 9 ;
     const int m = rand() % 9 ;
     const int n = rand() % 9 ;
     const int o = rand() % 9 ;
     const int p = rand() % 9 ;
     const int q = rand() % 9 ;
     const int r = rand() % 9 ;
{
      char transactionType;      
      cout << "Press N to cancel, and Y to continue:\n " << endl;
      cin  >> transactionType;

       if (transactionType == 'x' ||
           transactionType == 'X')
       {
           break;
       }
       
      if (transactionType == 'y' ||
          transactionType == 'y')
       {
       
continue ;
       
       }
     }
    {   
       cout << "abcdefghijklmnopqr";
      }
    }

errors:

break statement not within
continue statement not within
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;
int main ( int nNumberofArgs, char* pszArgs[] )
{
  srand ( ( unsigned ) time ( 0 ) );

  const int a = rand() % 9 ;
  const int b = rand() % 9 ;
  const int c = rand() % 9 ;
  const int d = rand() % 9 ;
  const int e = rand() % 9 ;
  const int f = rand() % 9 ;
  const int g = rand() % 9 ;
  const int h = rand() % 9 ;
  const int i = rand() % 9 ;
  const int j = rand() % 9 ;
  const int k = rand() % 9 ;
  const int l = rand() % 9 ;
  const int m = rand() % 9 ;
  const int n = rand() % 9 ;
  const int o = rand() % 9 ;
  const int p = rand() % 9 ;
  const int q = rand() % 9 ;
  const int r = rand() % 9 ;
  {
    char transactionType;
    cout << "Press N to cancel, and Y to continue:\n " << endl;
    cin  >> transactionType;

    if ( transactionType == 'x' ||
         transactionType == 'X' )
    {
      break;
    }

    if ( transactionType == 'y' ||
         transactionType == 'y' )
    {
      continue ;
    }
  }
  {
    cout << "abcdefghijklmnopqr";
  }
}

Most of your program doesn't make any sense. Should I elaborate or do you wanna look at a newbie tutorial?

Elaborate 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 of about 4 billion, and seing as i need a 17 digit number, i generate a number for each digit, when the person continues it prints out each digit in the end

Elaborate 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 of about 4 billion, and seing as i need a 17 digit number, i generate a number for each digit, when the person continues it prints out each digit in the end

Well dear Superfat, the most effective solution for you problem has already been given by vijayan121. Unfortunately you aren't able to understand his fine function. So GOD's advice should be seriously followed.

Btw, your nice random numbers a..r never contain 9, got it?

krs,
tesu

Comments
Aw shucks, I'm not really God, it's just that's what the girls scream when they're with me.
This question has already been answered. Start a new discussion instead.