hi every one
Im still new to programming i have downloaded borland compiler and was writing the following code:

#include<iostream>
using namespace std;
int main()
{
for (int x = 0; x < 10000000000; x++ ){
cout<< x << endl;
}cin.get();
}

the problem is that when it is done i cant scroll up to the first number.
My goal is to copy all those numbers into note pad please help!

Write them to a file.

And 10000000000 may be larger than an int on your machine (it's larger than an int on mine).

Write them to a file.

And 10000000000 may be larger than an int on your machine (it's larger than an int on mine).

well as i told you I'm still a beginner could you please tell me how to write them to file
and what do you mean by int 100000000000 is to large on my machine and please only answer this if you don't want to answer any of the above how can I obtain all those numbers in a file or something else
thank you for your time

In some worlds everything might work everywhere. However, in this world frequently there are rules that must be followed. For example, in the non-computing world integers can have infinite size, but in C++, the int type, which has been designed integers within written code, has an upper limit of size. The upper limit may vary from implementation. You can find out what the upper limit is on your machine by printing out ints sequentially or by looking in the limits header file.

#include<fstream>
using namespace std;
int main()
{
   ofstream fout("myfile.txt");

  for (int x = 0; x < 10000; x++ )
  {
      fout<< x << endl;
  }
  cin.get();
}

Then you can open the file called myfile using Notepad if you want.

In some worlds everything might work everywhere. However, in this world frequently there are rules that must be followed. For example, in the non-computing world integers can have infinite size, but in C++, the int type, which has been designed integers within written code, has an upper limit of size. The upper limit may vary from implementation. You can find out what the upper limit is on your machine by printing out ints sequentially or by looking in the limits header file.

#include<fstream>
using namespace std;
int main()
{
   ofstream fout("myfile.txt");

  for (int x = 0; x < 10000; x++ )
  {
      fout<< x << endl;
  }
  cin.get();
}

Then you can open the file called myfile using Notepad if you want.

thank you man

please only one more thing , I hope you dont find me annoying ,
now I have all the values from 1 to 10000000000
is there a way to do the same with all alphabet letter
see what i want to do is a have a doc. that has all the possible combination of the alphabet together and numbers together.
I really appreciate your time and help thank you.

please only one more thing , I hope you dont find me annoying ,
now I have all the values from 1 to 10000000000
is there a way to do the same with all alphabet letter
see what i want to do is a have a doc. that has all the possible combination of the alphabet together and numbers together.
I really appreciate your time and help thank you.

Sure, except now you are going to output strings or groups of characters to the file instead of integers. You need to decide whether you want both capital and lower case letters or one or the other. Let's assume you want numeric digits and upper case letters. You can think of the letters as "digits" too, so you have 36 "digits". If you are interested in all "three-digit" combinations, there are 36 to the 3rd power possibilities, so you could have some nested loops.

const int ASCII_DIGIT_OFFSET = 48; // '0' == Ascii 48
const int ASCII_LETTER_OFFSET = 55; // 'A' == Ascii 65
char digit1, digit2, digit3;

for (int i = 0; i < 36; i++)
{
     if (i < 10)
          digit1 = i + ASCII_DIGIT_OFFSET;
     else
          digit1 = i + ASCII_LETTER_OFFSET;
     
     for (int j = 0; j < 36; j++)
     {
          // do same for digit2 using j instead of i

          for (int k = 0; k < 36; k++)
          {
               // do same for digit3 with k instead of i
               fout << digit1 << digit2 << digit3 << endl;
          }
     }
}

So for each loop you are converting an integer from 0 - 35 into the character equivalent of that digit ('0' through '9' or 'A' through 'Z'), then you are outputting it to the file using the << operator as you did before. The above example uses three digits, but you can vary it.

> see what i want to do is a have a doc. that has all the possible combination of the alphabet
> together and numbers together.
Have you actually worked out how big that document would be?

Do you have that much disk space?

Do you have that much time?

If you take VernonDozier's approach out to say 10 characters, you're looking at a run-time measured in YEARS. Each character increase in length multiplies the run-time by 36.
So for example
All combinations of 5 chars takes 1 second
All combinations of 6 chars takes 36 seconds
All combinations of 7 chars takes 1296 seconds (about 20 mins)
All combinations of 8 chars takes 777 minutes (about 13 hours)
For 9, it's 450+ hours (or 20 days)
For 10, it's 700 days (or 2 years)

Sure, except now you are going to output strings or groups of characters to the file instead of integers. You need to decide whether you want both capital and lower case letters or one or the other. Let's assume you want numeric digits and upper case letters. You can think of the letters as "digits" too, so you have 36 "digits". If you are interested in all "three-digit" combinations, there are 36 to the 3rd power possibilities, so you could have some nested loops.

const int ASCII_DIGIT_OFFSET = 48; // '0' == Ascii 48
const int ASCII_LETTER_OFFSET = 55; // 'A' == Ascii 65
char digit1, digit2, digit3;

for (int i = 0; i < 36; i++)
{
     if (i < 10)
          digit1 = i + ASCII_DIGIT_OFFSET;
     else
          digit1 = i + ASCII_LETTER_OFFSET;
     
     for (int j = 0; j < 36; j++)
     {
          // do same for digit2 using j instead of i

          for (int k = 0; k < 36; k++)
          {
               // do same for digit3 with k instead of i
               fout << digit1 << digit2 << digit3 << endl;
          }
     }
}

So for each loop you are converting an integer from 0 - 35 into the character equivalent of that digit ('0' through '9' or 'A' through 'Z'), then you are outputting it to the file using the << operator as you did before. The above example uses three digits, but you can vary it.

i got it to work thank you very much but if i want to make it 8 digit what do i do? and why did you use
i j k
why not anything else?

i got it to work thank you very much but if i want to make it 8 digit what do i do? and why did you use
i j k
why not anything else?

You can name your loop variables whatever you want. I just used i, j, k since they are traditional loop counter names. To make it 8 digits, have 8 loops instead of 3. Use i,j,k,l,m,n,o,p or a,b,c,d,e,f,g,h or an array or whatever you want. Also keep in mind Salem's post. You have the time factor and you are also looking at 36^8 lines in the file, each of which is 9 characters (8 characters plus a newline), so you're looking at 9*36^8 bytes, or about 25 terabytes of disk storage. Also, my algorithm is doing a lot of adding for each loop to change it from an integer to a char and it's creating and destroying variables a lot, all of which takes time, which adds up. So my method is not the most efficient for this task and you would want to tweak it for something this big to speed it up and remove all that adding. I posted it that way since I thought it would be easier to understand, not for efficiency. Here is the expansion of my previous method to four digits. Do the same to make it 5,6,7, and 8 digits.

const int ASCII_DIGIT_OFFSET = 48; // '0' == Ascii 48
const int ASCII_LETTER_OFFSET = 55; // 'A' == Ascii 65
char digit1, digit2, digit3, digit4;

for (int i = 0; i < 36; i++)
{
     if (i < 10)
          digit1 = i + ASCII_DIGIT_OFFSET;
     else
          digit1 = i + ASCII_LETTER_OFFSET;
     
     for (int j = 0; j < 36; j++)
     {
          // do same for digit2 using j instead of i

          for (int k = 0; k < 36; k++)
          {
               // do same for digit3 with k instead of i
  
               for (int l = 0; l < 36; l++)
               {
                    // do same for digit4 with l instead of i            
                    fout << digit1 << digit2 << digit3 << digit4 << endl;
               }
          }
     }
}
This article has been dead for over six months. Start a new discussion instead.