DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: map data display

  1. #1
    Join Date
    Apr 2011
    Posts
    13

    map data display

    Hello everyone

    Could someone please tell me why are the contents of the map not displayed on the screen.

    Code:
    namespace conffile
    {  	   
    	struct data: std::map <std::string, std::string>
        	{
        		// something
        	};
    	  	
      	std::istream& operator >> ( std::istream& ins, data& d )
        	{
    	    	std::string s, key, value;
    		
    	    	while (std::getline( ins, s ))
    	      	{
    	      		// populate map
    			
    			
    			// the program does display the KEY VALUE pair through the code below
    			cout << "key: " << key << "\nvalue: " << value << endl;
    			
    	      		d[key] = value;
          		}
    
        		return ins;
    	}
    	
    	// but The program does not display the map data through the code below *** any idea why?
    	// am I doing it the wrong way and is there any other way to display it?
      	std::ostream& operator << ( std::ostream& outs, const data& d )
        	{
        		data::const_iterator iter;
        		
        		for (iter = d.begin(); iter != d.end(); iter++)
          			outs << iter->first << " = " << iter->second << endl;
        		return outs;
        	}
    
    } // namespace conffile
    Many thanks in advance

  2. #2
    Join Date
    Dec 2007
    Posts
    401
    Looks fine to me. Can't think of a reason why it shouldn't work.

Similar Threads

  1. how to display & receive serial data in vb6
    By dannycool in forum .NET
    Replies: 2
    Last Post: 04-16-2010, 12:21 PM
  2. Importing Excel Data
    By rrjii2000 in forum .NET
    Replies: 10
    Last Post: 03-26-2010, 01:34 PM
  3. Combobox that display data from ITS OWN TABLE
    By crystalelle in forum .NET
    Replies: 9
    Last Post: 03-09-2008, 10:58 PM
  4. XSL to display data in columns.
    By Ron in forum XML
    Replies: 2
    Last Post: 04-11-2003, 05:38 PM
  5. Replies: 0
    Last Post: 08-23-2000, 10:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center