hey there i have a question for you guys.
my program reads a file and then save each line of the file into a multimap<string,int> containing the string and the number line.
i have the convert strings in alphabetical order, like take into aetk, and thats where the problem begins because i cant do that with multimaps,, only with char arrays.
take --> aekt
kate --> aekt

im using multimap because the program has to save pretty fast the words from the file.
thanx :)

why do you need a multimap and not a vector of strings? I doubt you're going to save any time by using a map. It's also not evident why you need the line number to do this, either.

An STL string is nothing more than a glorified C style string. You can get an equivalent C style string to work with by calling the c_str() method.

sort before inserting the string into the multimap?

void fill_mmap( std::multimap< std::string, int >& mmap,
                std::ifstream& file )
{
  std::string line ;
  for( int line_num = 1 ; std::getline( file, line ) ; ++line_num )
  {
    std::sort( line.begin(), line.end() ) ;
    mmap.insert( std::make_pair( line, line_num ) ) ;
  }
}

thanx a lot vijayan121, your code fixed the problem.
i really appreciate your help. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.