Click here to Skip to main content
15,894,328 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Sharing the socket FD cross process Pin
CPallini29-Dec-09 21:30
mveCPallini29-Dec-09 21:30 
QuestionAFX_MANAGE_STATE (AfxGetStaticModuleState ()) not working Pin
Karismatic29-Dec-09 19:18
Karismatic29-Dec-09 19:18 
AnswerRe: AFX_MANAGE_STATE (AfxGetStaticModuleState ()) not working Pin
KingsGambit29-Dec-09 19:45
KingsGambit29-Dec-09 19:45 
GeneralRe: AFX_MANAGE_STATE (AfxGetStaticModuleState ()) not working Pin
Karismatic29-Dec-09 21:16
Karismatic29-Dec-09 21:16 
GeneralRe: AFX_MANAGE_STATE (AfxGetStaticModuleState ()) not working Pin
Madhu Nair29-Dec-09 21:43
Madhu Nair29-Dec-09 21:43 
Questionsending wav files using UPD protocol in vc++ Pin
janaswamy uday29-Dec-09 18:56
janaswamy uday29-Dec-09 18:56 
AnswerRe: sending wav files using UPD protocol in vc++ Pin
KingsGambit29-Dec-09 19:55
KingsGambit29-Dec-09 19:55 
AnswerRe: sending wav files using UPD protocol in vc++ Pin
raja jamwal31-Dec-09 8:22
raja jamwal31-Dec-09 8:22 
GeneralRe: sending wav files using UPD protocol in vc++ Pin
janaswamy uday1-Jan-10 23:44
janaswamy uday1-Jan-10 23:44 
Question[Resolved] CButtonST question, Remove the residue of old icon while setting a new icon with SetIcon [modified] Pin
Maxwell Chen29-Dec-09 18:51
Maxwell Chen29-Dec-09 18:51 
AnswerRe: CButtonST question, Remove the residue of old icon while setting a new icon with SetIcon Pin
KingsGambit29-Dec-09 19:47
KingsGambit29-Dec-09 19:47 
GeneralRe: CButtonST question, Remove the residue of old icon while setting a new icon with SetIcon Pin
Maxwell Chen29-Dec-09 20:03
Maxwell Chen29-Dec-09 20:03 
QuestionToolBar in singe document view Pin
Anu_Bala29-Dec-09 18:25
Anu_Bala29-Dec-09 18:25 
Questionmap Pin
ratprita29-Dec-09 17:35
ratprita29-Dec-09 17:35 
AnswerRe: map Pin
KingsGambit29-Dec-09 17:54
KingsGambit29-Dec-09 17:54 
GeneralRe: map Pin
ratprita29-Dec-09 18:08
ratprita29-Dec-09 18:08 
GeneralRe: map Pin
Tim Craig29-Dec-09 18:11
Tim Craig29-Dec-09 18:11 
GeneralRe: map Pin
KingsGambit29-Dec-09 18:23
KingsGambit29-Dec-09 18:23 
QuestionRe: map Pin
CPallini29-Dec-09 21:18
mveCPallini29-Dec-09 21:18 
AnswerRe: map Pin
ratprita29-Dec-09 21:23
ratprita29-Dec-09 21:23 
GeneralRe: map Pin
CPallini29-Dec-09 22:11
mveCPallini29-Dec-09 22:11 
You may use a map whoose key is a string containing the name and whose value is a vector of string (each of the latter containing one of 'value1', 'value2', etc...). For instance:


#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;

int main()
{ 
   // the map containing the 'name' and a vector of 'value's 
   map <string, vector <string > > item;
   const int SIZE=0x100;
   char buf[SIZE];
   ifstream ifs("foo.txt");
   while (ifs.getline(buf,SIZE).good())
   {
     size_t m, n;
     string s(buf);
     string name;
     vector <string> value;
     if ( (m=s.find('\t')) != string::npos)
     {
       name = s.substr(0,m);
       while ((n=s.find(' ',m+1)) !=string::npos)
       {
          value.push_back( s.substr(m+1,(n-m)));
          m=n;
       }
       value.push_back(s.substr(m+1));
       item.insert(make_pair(name,value));
     } 
   }

  // now dump all found items
   map <string, vector <string > >::iterator itm;
   for ( itm = item.begin(); itm != item.end(); itm++)
   {
      cout << "name = " << itm->first << endl;
      vector <string>::iterator itv;
      for ( itv = itm->second.begin(); itv != itm->second.end(); itv++)
      {
        cout << '\t' << *itv << endl;
      }
   }
} 


Please note: code should be made more robust (it isn't robust at all). That's left as exercise to the reader.

Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

JokeRe: map Pin
Maxwell Chen29-Dec-09 21:23
Maxwell Chen29-Dec-09 21:23 
QuestionTrouble loading a driver Pin
Mattzimmerer29-Dec-09 13:05
Mattzimmerer29-Dec-09 13:05 
AnswerRe: Trouble loading a driver Pin
Maxwell Chen29-Dec-09 19:06
Maxwell Chen29-Dec-09 19:06 
GeneralRe: Trouble loading a driver Pin
Mattzimmerer30-Dec-09 0:48
Mattzimmerer30-Dec-09 0:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.