1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

figuring out how to use a map

Discussion in 'C++' started by helpme87, Aug 30, 2010.

  1. helpme87

    helpme87 New Member

    Aug 30, 2010
    Likes Received:
    Trophy Points:
    so i am trying to write a program that reads some data in from a text file and performs an operation on that data. the text file is as follows...

    611111 5
    765676 4
    876787 4
    987897 2
    611111 4
    now i want the program to read that and see that 611111 is there twice and will add its corresponding values so 611111 will then have a corresponding value of 9. i did some research and found out a map is probably what i need to do this but thats where i am getting confused. im not exactly sure how to read the data into the map from a text file and then how to pick out if there are any similar numbers in the first column.

    im not even sure why i am posting what i have so far since i know it is probably embarressingly wrong (especially since i have been working on this for a couple days now). thank you ahead of time!!!

    oh and i am using dev-c++ so i cant use strings

    char accountNum[6];
    int amount;

    map report;

    while (!inLN.eof())

    report[accountNum] = amount;


Share This Page