Let's see if this works
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Let's see if this works

  1. #1
    Join Date
    May 2002
    Location
    Quebec City, Canada
    Posts
    374

    Let's see if this works

    Code:
    #include "stdafx.h"
    #include <map>
    #include <string>
    #include <iostream>
    
    using namespace std;
     
    
    // Using a string object for both the key 
    // and the item
    #pragma warning ( disable : 4786 )
    typedef multimap<string, string> NameList;
    
    typedef NameList::iterator NameIt;
    
    int main()
    {
      NameList Names;
      NameIt CurrentName;
    
      // An example of adding one element 
      // to the map:
      string NameA1 = "Patty Anderson";
      string NameA2 = "Anderson";
      Names.insert
        (NameList::value_type(NameA2, NameA1));
    
      // This is the code I am trying to use to 
      // output the list to the console:
    /*
      for( CurrentName = Names.begin(); CurrentName != Names.end(); CurrentName++);
      {
      // Program crashes here. 
      cout << static_cast<string>(CurrentName->second) << endl;
    
      } 
    */
      CurrentName = Names.begin();
    
      while( CurrentName != Names.end() )
      {
        cout << (*CurrentName).second;
        cout << endl;
        ++CurrentName;
      }
    
      for( CurrentName = Names.begin(); CurrentName != Names.end(); CurrentName++ )
      {
        cout << (*CurrentName).second <<endl;
        cout << endl;
      }
    
        return 0;
    }
    Martin Breton
    3D vision software developer and system integrator.

  2. #2
    Join Date
    May 2002
    Location
    Quebec City, Canada
    Posts
    374
    Code:
    CFiddleDi::Prociekt()
    Martin Breton
    3D vision software developer and system integrator.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center