mea culpa, il metodo e' push_back() e non push()
il vc++ 6 dovrebbe darti l'autocompletamento...
			Moderatori: cb_123, thrantir, tonertemplum


#include <list>
#include <fstream>
#include <sstream>
#include <iostream>
    
void getWords(int aLength, std::list<std::string>& aList)
{
    for(char myChar = 'a'; myChar < 'z'; ++myChar)
    {
        std::stringstream myPrefix;
        myPrefix << "italiano." << myChar;
        std::ifstream myVocabulary(myPrefix.str().c_str());
        if(myVocabulary.good())
        {
            std::string myLine;
            while(getline(myVocabulary, myLine))
            {
                if(aLength == myLine.length())
                {
                   aList.push_back(myLine);
                }
            }
        }
    }
}
    
int main(int argc, char* argv)
{
    for(int myIndex = 1; myIndex <= 4; ++myIndex)
    {
        std::list<std::string> myList;
        getWords(myIndex, myList);
        std::list<std::string>::const_iterator myIter;
        for(myIter = myList.begin(); myIter != myList.end(); ++myIter)
        {
            std::cout << *myIter << " ";
        }
        std::cout << std::endl;
    }
}
std::stringstream myPrefix; 
        myPrefix << "italiano." << myChar; 
        std::ifstream myVocabulary(myPrefix.str().c_str()); 
        if(myVocabulary.good())
 



#include <iostream> 
#include <list> 
#include <fstream> 
#include <sstream>     
void createList(int aLength, std::list<std::string>& aList) 
{ 
    for(char myChar = 'a'; myChar < 'z'; ++myChar) 
    { 
        std::stringstream myPrefix; 
        myPrefix << "italiano." << myChar; 
        std::ifstream myVocabulary(myPrefix.str().c_str()); 
        if(myVocabulary.good()) 
        { 
            std::string myLine; 
            while(getline(myVocabulary, myLine)) 
            { 
                if(aLength == myLine.length()) 
                { 
                   aList.push_back(myLine); 
                } 
            } 
        } 
    } 
} 
void findWord (char )
{
}
void getParam (int &aLength, char &str[])
{
     std::cout << "inserisci la lunghezza che deve avere la parola: " ;
     std::cin >> aLength;
     std::cout << "inserisci la sillaba che ricerchi: " ;
     std::cin >> str;
} 
void stampList (std::list<std::string> &aList)
{
     std::list<std::string>::const_iterator myIter; 
     for(myIter = aList.begin(); myIter != aList.end(); ++myIter) 
          { 
             std::cout << *myIter << "\n"; 
          } 
    std::cout << std::endl;
}
int main(int argc, char* argv) 
{ 
    int aLength,prossimo;
    bool risp = true;
    char str[]="aaaaa";
    while(risp == true)
     {     
           getParam (aLength,str);
          // std::cin >> aLength;
           std::list<std::string> aList; 
           createList(aLength, aList); 
           stampList(aList);
           std::cout << "prossimo?";
           std::cin >> prossimo;
           if(prossimo != 1)
                       risp = false;
   }
}getParam (aLength,str);void getParam (int &aLength, char &str[])
void findWord (char str[], std::list<std::string>& aList, std::list<std::string> &finalList)
{char *pnt;
     std::list<std::string>::const_iterator myIter; 
     for(myIter = aList.begin(); myIter != aList.end(); ++myIter) 
          { 
          pnt = strstr(*myIter,str)
             if(pnt != 1)
                  finalList.push_back(*myIter);                   
          } 
    std::cout << std::endl;
}

void findWord (std::string aStringToFind, std::list<std::string>& aList, std::list<std::string> &finalList)
{
     std::list<std::string>::const_iterator myIter;
     for(myIter = aList.begin(); myIter != aList.end(); ++myIter)
     {
          if(myIter->find(aStringToFind) != myIter->npos)
          finalList.push_back(*myIter);                   
     }
     std::cout << std::endl;
}



Visitano il forum: Nessuno e 1 ospite