February 23rd, 2013 08:55 PM
#1
Programming Debugging help....
I have been on this program pretty much the whole day started it from scratch now i am stuck getting
"Unhandled exception at 0x7531812f in testingCodes.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x00211370.."
but i can't figure it out so before i change some of my codes I will hope someone could point out the problem here.
Thanks in advance...
//This program open three files each has 1000 names that i utilize to create email as many unique email addresses i could get
//2000 first names and 1000 last names i have come to the point where i could generate the email addresses but I still have lef//t to let the user enter how many millions of email wants to generate based on that generate that amount
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <cmath>
using namespace std;
#define MAX 100000
string emails[MAX];
int main()
{
int e, f, ff, gf, i, j, k, l, m, n, num;
char Init[1000];
string STRING1;
string STRING2;
string STRING3;
string adds[5] = {"@hotmail.com", "@yahoo.com", "@gmail.com", "@msn.com", "@excite.com"};
string ffstName[1000];
string gfstName[1000];
string lstNames[1000];
string InitL[1000];
string emailsL[5000];
string emailsI[5000];
ifstream infile1;
ifstream infile2;
ifstream infile3;
infile1.open ("fmlsFName.txt");
infile2.open ("guysFName.txt");
infile3.open ("LstName.txt");
cout << "Enter the number of emails to generate in millions: " ;
cin >> num;
cout <<endl;
int cnt = num * 1000, cntEAd = 1, maxCnt = MAX/(cnt);
//cout <<endl;
//cout << "Here where it starts entering the LADIES email address" <<endl;
//cout <<endl;
//do
//{
while(getline(infile1, STRING1))
{//ff for females first name count
for(ff = 0; ff < 999; ++ff)
{
infile1 >> ffstName[ff];
for(n = 0; n < lstNames[ ff ].size(); ++n)
// InitF[n] = lstNames[n][0];
for(i = 0; i < 5; i++)
{
// cout << ffstName[ff];
// cout << adds[i] <<endl;
}
}
}
//cout <<endl;
//cout << "Here where it starts entering the GUYS email address" <<endl;
//cout <<endl;
//system("pause");
while(getline(infile2, STRING2))
{//gf for guys first name count
for(gf = 0; gf < 999; ++gf)
{
infile2 >> gfstName[gf];
for(n = 0; n < lstNames[ gf ].size(); ++n)
// InitG[n] = lstNames[n][0];
for(i = 0; i < 5; i++)
{
// cout << gfstName[gf];
// cout << adds[i] <<endl;
}
}
}
//cout <<endl;
//cout << "Here where it starts entering email address based on LAST NAME" <<endl;
//cout <<endl;
//system("pause");
while(getline(infile3, STRING3))
{
for(l = 0; l < 999; ++l)
{//l for last name count
infile3 >> lstNames[l];
for(n = 0; n < lstNames[ l ].size(); ++n)
InitL[n] = lstNames[n][0];
for(i = 0; i < 5; i++)
{
// cout << lstNames[l] + adds[i] <<endl;
// cout << Init[n] + adds[i] <<endl;
emailsL[l] = lstNames[l] + adds[i];
emailsI[n] = Init[n] + adds[i];
}
}
}
for(e = 0; e < MAX; e++)
{//e for email address count
emails[e] = emailsL[e];
cntEAd++;
}
cout << "The number of emails generated are: " << cntEAd <<endl;
//}while(cntEAd <= cnt);
/*
for(f = 0; f < num - 1; f++)
{//f for first name count ex: fstName[0] = abiye
for(l = 0; l < 999; l++)
{//l for last name count ex: lstName[0] = ketema
for(i = 0; i < 5; i++)
{//i for email prvdrs count ex: abiyeketema@hotmail.com
cout << ffstName[f] + lstNames[l] + adds[i] <<endl;
cout << InitF[f] +"_"+lstNames[l] + adds[i] <<endl;
cout << gfstName[f] + lstNames[l] + adds[i] <<endl;
cout << InitG[f] +"_"+lstNames[l] + adds[i] <<endl;
cout << lstNames[l] + ffstName[f] + adds[i] <<endl;
cout << InitL[l] +"_"+ffstName[f] + adds[i] <<endl;
cout << lstNames[l] + gfstName[f] + adds[i] <<endl;
cout << InitL[l] +"_"+gfstName[f] + adds[i] <<endl;
cout << InitL[l] + "_" + InitF[f] + adds[i] <<endl;
cout << InitL[l] + "_" + InitG[f] + adds[i] <<endl;
}
}
}
*/
infile1.close();
infile2.close();
infile3.close();
system ("pause");
return 0;
}
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks