jesseb07 64 Junior Poster

looks like there's a couple things, I don't think that would even compile: comparing a map<int, vector<int> >::iterator to an int inside your loop doesn't seem safe to me. As well as not declaring the map type for your iterator.

anyway, see if this is a good starting point:

map<int, vector<int> > my_map; //I assume these are global or in a class, as you had it
map<int, vector<int> >::iterator it;

void erase(int num)
{
    for(it = my_map.begin(); it != my_map.end(); it++)
    {
        if((*it).first == num)
        {
            my_map.erase(it);
            break;
        }
    }
}

I think that's what you were going for, hope that's helpful

~J

jesseb07 64 Junior Poster

For some reason, my numbers aren't adding in correctly and it's taking the -1 sentinel value and adding it into the total.

// worthless testing.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using std::cout;
using std::cin;
using std::endl;


int main()
{
int number = 0;
int total = 0;
do
{
	cout<<"Enter a number: ";
	cin>>number;
	total = total + number;
} while (number != -1);

cout<<"Total is:"<<total<<endl;
	return 0;
}

to answer the OP's question, here's why the total is being affected in a way that you don't think it should. Go through your loop and see what's happening sequentially:
1. tell the user to enter a number
2. get the number
3. add the number to the total (regardless of what it is)
4. exit if the number is -1

simple fix (that utilizes 99% of your original code ;) ) :

total = total + number; //change this to:

if(number != -1) //this
     total += number //with this

now here's what's happening:
1. tell the user to enter a number
2. get the number
3. add the number to the total if it's not -1
4. exit if the number is -1

hopefully that's helpful as well, while it pales to tux's thesis :P

there is another way of doing it (for completeness sake) with a conditional break inside of the loop, but can't say it's the preferred …

tux4life commented: Yes, this post is also valuable in this thread :) +13
jesseb07 64 Junior Poster

I personally generally use an EVENT_TABLE if I have a large number of events for a class ( > 5 or so), but if I only have 1 or 2 I generally use Connect (or I have a complicated gui, lots of enabling/disabling etc). I've just found it to look cleaner: prevents a ridiculous amount of event tables but if there's a ton of events it's easier to keep them straight in an event table. That's my preference, there are some different things that can be done with connect so it's not a straight substitute either way, but if you want something more than that, here's explaining the subtle differences:

http://wxwidgets.blogspot.com/2007/01/in-praise-of-connect.html

Also, another interesting bit of info is that in my wxwidgets book, written by the creators, all of their examples (that I've seen) use event tables. It's possible that there's performance differences (significant I mean) since event tables are static routing and connect is dynamic but I have yet to see anything definitive so I'm going by what I like :)

hope that's helpful

~J

Nick Evan commented: Good post +18
jesseb07 64 Junior Poster

everyone gets heckled a bit from time to time, don't let it bother you.

Now, per your request regarding the program.

I will try to convince you that it is a bad idea for a beginner.

1st. 6month old babies don't learn to drive on the autobahn (take the analogy)
2nd. Notice EVERY tutorial on "Your very first [insert language here] script" is a "Hello World" and not Halo 3, there is a definite reason for that

You've gotta start somewhere, it's true, but try crawling (Hello World) before flying. Should you embark on this project anyway, you will find that you will not learn much (if anything) because without a good foundation in the basics and even intermediate concepts, it will be baffling.

Take the advice of someone who's been coding for 7 years that this is too much for you.

I can make an awful lot of very nice things on paper (like an anti-gravity machine for example), but that's essentially saying the same thing as "Hey I drew a picture!" the implementation is always the tricky part.

~J

Salem commented: Well said +20
jesseb07 64 Junior Poster

ah, I've never dealt with vectors before either (this is turning into quite the learning experience), and you were correct, they work wonderfully. If you remember what my code looked like before (I think I only posted about half of it) here's the whole thing:

vector<string> data_to_array()
{
       vector<string> data;
       string temp="";
       ifstream file("user_data.txt");
       if(file.is_open() && (file_check() == true)) //checks to see if file is open and not empty
       {
                while(file >> temp) //gets words seperated by whitespace
                {
                        data.push_back(temp);
                }
       }
       return data;
}

That's the finished version and works like a charm (but I also thought the other things worked ;) ) Thank you for all your help!

~J

Dave Sinkula commented: Thank you. This was a diamond in the rough for me. +13