3 Replies - 516 Views - Last Post: 11 May 2010 - 05:56 AM Rate Topic: -----

#1 Guest_Sammy H*



Posted 10 May 2010 - 04:09 PM

Hi there, just trying to write the main function of my project. Reading in a list of strings and floats from a text file. Was just wondering whats the best way to get all the information stored in a map? i then have to be able to use prims algorithm on that map later on.

using namespace std;

/*Author: Sam Hardman

void prims();
void split();
int display(map<string, int>m);

ifstream inStream;
map <string,int>m;

int main()
    char getch;
    string Fname;
    string temp = " ";
    int wordIndex = -1;
    cout << "please enter the name of the text file" << endl;
    cin >> Fname;

        cerr << "There is a problem opening your text file" << endl;
        cerr << "Please make sure your file exists" << endl;
        return EXIT_FAILURE;}


    //read into map.?



This post has been edited by JackOfAllTrades: 10 May 2010 - 04:57 PM
Reason for edit:: Fixed code tags.

Is This A Good Question/Topic? 0

Replies To: maps

#2 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: maps

Posted 10 May 2010 - 09:32 PM


Reading in a list of strings and floats from a text file

Then why is the map defined like this?
map <string,int>m;

Also, what makes you think that a map is the best for this task? Could you post an example of your file's data?
Was This Post Helpful? 0
  • +
  • -

#3 Guest_sammy H*


Re: maps

Posted 11 May 2010 - 05:47 AM

yeah fixed that up, we have to use a map, cause were learning about maps at the moment.
input data is like this:
where Epping and marsfield are a point on a map, and 6.5 is the distance between them.

Was This Post Helpful? 0

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: maps

Posted 11 May 2010 - 05:56 AM

Have a read here:
and here
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1