-1

一部のhtmlからメールを取得するためのメール抽出関数を作成しています。途中でメモリ アクセス違反エラーが発生し始めたので、ブレークポイントを使用してクラッシュの開始場所を特定し、メモリ アクセス違反の原因となっている行にコメントを付けました。誰かが私のエラーを解決するのを手伝ってください:)ありがとう!コードは次のとおりです。

void extractEmail(const char* html)
{
    std::string htmls = html;
    int pos = 0;
    int amountOfEmails = 0;
    std::vector<int> emailAtPoints;
    std::vector<int> startOfEmail;
    std::vector<int> endOfEmails;
    while(pos != -1)
    {
        pos = htmls.find("@",pos+1);
        if(pos == -1)
            break;
        emailAtPoints.push_back(pos);
        amountOfEmails++;
    }
    for(std::vector<int>::iterator itr = emailAtPoints.begin(); itr != emailAtPoints.end(); ++itr)
    {
        std::cout << "There was found an @ sign at: " << *itr << std::endl;
    }
    pos = 0;
    unsigned int current = 0;
    while(pos != -1)
    {
        // Get position for start of email
        pos = htmls.rfind(" ",emailAtPoints.at(current)+1);
        if(pos == -1)
            break;
        startOfEmail.push_back(pos); // Add to vector
        // Get position for end of email
        pos=htmls.find(" ",emailAtPoints.at(current)+1);
        if(pos == -1)
        {
            startOfEmail.pop_back(); // Destroy last element.
            break;
        }
        endOfEmails.push_back(pos); // Add
        if(current < emailAtPoints.size())
            current++;
        else
            break;
    }
    for(std::vector<int>::iterator itr = startOfEmail.begin(); itr != startOfEmail.end(); ++itr) // This thing crashes it --- Memory Access Violation
    {
        std::cout << "The numbers for where every email starts at: " << *itr << " ";
    }
    std::cout << std::endl;
    for(std::vector<int>::iterator itr = endOfEmails.begin(); itr != endOfEmails.end(); ++itr)
    {
        std::cout << "The numbers for where every email ends   at: " << *itr << std::endl;
    }
    std::cout << std::endl;
    std::cout << "done";
}
4

1 に答える 1

0

文字列は CSS スクリプトを指す必要がありますが、そうではないようです。また、フロント ヘッダーで CMS をコンパイルしていません。これは、このタイプのコードが機能するために非常に重要です。

また、文字列を編集して、int 電流をデコードできるようにします。あなたの作り方は非常に下手で、不要なコードがたくさんあります。

これも変更します:

 {
    pos = htmls.find("@",pos+1);
    if(pos == -1)
        break;
    emailAtPoints.push_back(pos);
    amountOfEmails++;

この中に

 {
    pos = htmls.find("@",pos+1);
    if(pos == -1)
      point cssthings
      execute defluxinator
        break;
    emailAtPoints.push_back(pos);
    amountOfEmails++;

私が助けてくれることを願っています。幸運を :)

于 2013-05-27T17:44:37.617 に答える