hi can u help me i want to make a program that write from 4.0.0.0.000 to 5.0.0.0.000 in a txt file
i made it but it make only one number like"4.0.0.0.001"
and then overwrite on it the next number can u tell me how to make each number in its own line or write the code here is my code
CODE
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream myfile ("example.txt");
int num1=4, num2=0, num3=0, num4=0, num5=0;
while(num1==4)
{
num2=0;
while(num2<=9)
{
num3=0;
while(num3<=9)
{
num4=0;
while(num4<=9)
{
num5=0;
while(num5<=999)
{
ofstream myfile;
myfile.open ("example.txt");
myfile <<num1<<"."<<num2<<"."<<num3<<"."<<num4<<"."<<num5<<endl;
myfile.close();
cout<<num1<<"."<<num2<<"."<<num3<<"."<<num4<<"."<<num5<<endl;
num5++;
}
num4++;
}
num3++;
}
num2++;
}
num1++;
}
cout<<"5.0.0.0.000";
return 0;
}
This post has been edited by dragonsword1: 7 Feb, 2007 - 03:26 AM