CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    Feb 2013
    Posts
    10

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

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Programming Debugging help....

    No help provided for a program to generate spamming emails!!!!!

  3. #3
    Join Date
    Feb 2013
    Posts
    10

    Re: Programming Debugging help....

    This is my homework assignment, I don't have any intention to use this to spam anyone.

  4. #4
    Join Date
    Feb 2013
    Posts
    10

    Re: Programming Debugging help....

    This is my homework assignment no intention what so ever to spam anyone...

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Programming Debugging help....

    Then your tutor should choose more appropriate homework assignments!! These pages are public viewable so again, no help provided for a program that could be used to generate spamming emails!

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Programming Debugging help....

    Quote Originally Posted by soccerstr View Post
    This is my homework assignment no intention what so ever to spam anyone...
    Keep in mind most of us that have been here a while have been through school and seen lots of homework, both assigned to us and posted to others here. Also keep in mind, most of us make our living because we're relatively intelligent. With those things in mind, please go away.

  7. #7
    Join Date
    Feb 2013
    Posts
    10

    Re: Programming Debugging help....

    really u guys don't believe me? I am not insulting anybodies intelligence here, I am honestly seeking for help. I could scan my homework and post it here if that is necessary.

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Programming Debugging help....

    Quote Originally Posted by soccerstr View Post
    really u guys don't believe me? I am not insulting anybodies intelligence here, I am honestly seeking for help. I could scan my homework and post it here if that is necessary.
    This is a forum for legitimate programming and takes a really dim view of hacking and spamming. Go ahead and scan it and it if you like, but if that's really homework, your teacher has some serious problems with ethics and judgement.

  9. #9
    Join Date
    Feb 2013
    Posts
    10

    Re: Programming Debugging help....

    Here is the homework, Thanks for all the assistance in advance... -aK>
    Name:  photo (4).jpg
Views: 1611
Size:  97.5 KB

  10. #10
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Programming Debugging help....

    Crazy. Well I'll give you a kick in the right direction. Look at the difference in size between MAX and some of the arrays you're looping over MAX times.

  11. #11
    Join Date
    Feb 2013
    Posts
    10

    Re: Programming Debugging help....

    OK, Thanks that is a pretty good clue... I know it's crazy and this class is not even programming intensive class even though I like the challenge. Regards, -aK>

  12. #12
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Programming Debugging help....

    Quote Originally Posted by soccerstr View Post
    OK, Thanks that is a pretty good clue... I know it's crazy and this class is not even programming intensive class even though I like the challenge. Regards, -aK>
    Why not just ask you to generate random strings, random numbers, etc.? Why emails? Why certain ones such as hotmail, gmail, etc.?

    The teacher is using you to generate emails to spam with. If I'm wrong let him/her come to this forum and explain why this type of assignment was given.

    Regards,

    Paul McKenzie

  13. #13
    Join Date
    Feb 2013
    Posts
    10

    Re: Programming Debugging help....

    I don't know what his intention is but I think he is trying see we could actually implement something with that magnitude and the Algorithms to make it fast. My previous homework last week was generating unique ip address. I was able to generate as many ip address as i can but wasn't able make it unique getting rid of the duplication and fast so didn't submit that. That's why i am seeking for help now, I am trying make it through this class hopefully.

    I am really frustrated because I have other four programs I have to write from another class and not enough time in the day to do all of them. I don't mind sitting down here and figuring it out if i could get it done on time.

  14. #14
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Programming Debugging help....

    Quote Originally Posted by soccerstr View Post
    I don't know what his intention is but I think he is trying see we could actually implement something with that magnitude and the Algorithms to make it fast. My previous homework last week was generating unique ip address. I was able to generate as many ip address as i can but wasn't able make it unique getting rid of the duplication and fast so didn't submit that.
    And did this teacher show his/her solution? And again, why ip addresses? Why not an assignment to generate n sets of numbers, where each set is unique?

    This generation of ip addresses, emails with hotmail, gmail, and yahoo addresses, etc. sounds like your teacher is into spamming, and seeing if you can spam with the best of them. There are much better ways to teach algorithms than to ask you to write spamming programs. What's next, teach you OS internals by writing a virus?

    Regards,

    Paul McKenzie

  15. #15
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Programming Debugging help....

    Its no good sending me private emails asking for help either. Whether this is a genuine assignment or not is irrelevant. I repeat, no help given for any code relating to spamming for whatever reason.

    If this is a genuine assigment from a tutor my advice is to ditch the class and take another whch has an ethical approach to teaching programming!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured