<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[2 unterschiedliche CStrings vergleichen]]></title><description><![CDATA[<p>moin,</p>
<p>ich habe ein Problem, ich habe 2 CStrings str1, str2. In beiden CStrings stehen unterschiedliche Kürzel, alphabetisch sortiert, jeweils mit einem &quot;;&quot; als Trenner.</p>
<p>Also beispielsweise:</p>
<p>str1 = abc;def;gh;zyxv;zz<br />
str2 = def;jkl;opq;rst;uv;zz</p>
<p>Beide CStrings können unabhängig voneinander verschiedene Kürzel aufweisen, mein Ziel ist nun, die Kürzel zu finden, die in beiden CStrings vorhanden sind. Gibt es hierfür noch eine bessere Möglichkeit, als eine der beiden CStrings anhand der &quot;;&quot; erst zu zerlegen und jeden einzelnen der zerlegten Substring in dem anderen CString suchen zu lassen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/187650/2-unterschiedliche-cstrings-vergleichen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 01:09:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/187650.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Jul 2007 15:02:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 2 unterschiedliche CStrings vergleichen on Sun, 22 Jul 2007 15:02:10 GMT]]></title><description><![CDATA[<p>moin,</p>
<p>ich habe ein Problem, ich habe 2 CStrings str1, str2. In beiden CStrings stehen unterschiedliche Kürzel, alphabetisch sortiert, jeweils mit einem &quot;;&quot; als Trenner.</p>
<p>Also beispielsweise:</p>
<p>str1 = abc;def;gh;zyxv;zz<br />
str2 = def;jkl;opq;rst;uv;zz</p>
<p>Beide CStrings können unabhängig voneinander verschiedene Kürzel aufweisen, mein Ziel ist nun, die Kürzel zu finden, die in beiden CStrings vorhanden sind. Gibt es hierfür noch eine bessere Möglichkeit, als eine der beiden CStrings anhand der &quot;;&quot; erst zu zerlegen und jeden einzelnen der zerlegten Substring in dem anderen CString suchen zu lassen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1330250</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330250</guid><dc:creator><![CDATA[Herbie]]></dc:creator><pubDate>Sun, 22 Jul 2007 15:02:10 GMT</pubDate></item><item><title><![CDATA[Reply to 2 unterschiedliche CStrings vergleichen on Sun, 22 Jul 2007 15:28:35 GMT]]></title><description><![CDATA[<p>ich wuerde beide strings in die kuerzel auftrennen, nach dem alphabet sortieren und dann beide listen vergleichen. hast beim vergleichen am wenigsten aufwand.</p>
<p>Meep Meep</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1330254</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330254</guid><dc:creator><![CDATA[Meep Meep]]></dc:creator><pubDate>Sun, 22 Jul 2007 15:28:35 GMT</pubDate></item><item><title><![CDATA[Reply to 2 unterschiedliche CStrings vergleichen on Sun, 22 Jul 2007 15:34:20 GMT]]></title><description><![CDATA[<p>ja, so könnte man das machen.</p>
<p>Trööt Trööt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1330256</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330256</guid><dc:creator><![CDATA[Trööt Trööt]]></dc:creator><pubDate>Sun, 22 Jul 2007 15:34:20 GMT</pubDate></item><item><title><![CDATA[Reply to 2 unterschiedliche CStrings vergleichen on Sun, 22 Jul 2007 15:35:49 GMT]]></title><description><![CDATA[<p>Man könnte die Kürzel aber auch gleich mit Hilfe der unique Funktion in eine Liste einfügen, dann kommt jedes Kürzel nur einmal vor.</p>
<p>Balla Balla</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1330258</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330258</guid><dc:creator><![CDATA[Balla Balla]]></dc:creator><pubDate>Sun, 22 Jul 2007 15:35:49 GMT</pubDate></item><item><title><![CDATA[Reply to 2 unterschiedliche CStrings vergleichen on Sun, 22 Jul 2007 15:37:15 GMT]]></title><description><![CDATA[<p>Wenn die doppelt vokommenden Kürzel nicht interessieren und nicht gespeichert werden, ist deine ( Balla Balla ) Lösung optimal.</p>
<p>Plem Plem</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1330259</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330259</guid><dc:creator><![CDATA[Plem Plem]]></dc:creator><pubDate>Sun, 22 Jul 2007 15:37:15 GMT</pubDate></item><item><title><![CDATA[Reply to 2 unterschiedliche CStrings vergleichen on Sun, 22 Jul 2007 16:03:11 GMT]]></title><description><![CDATA[<p>Wie soll unique dabei helfen - müsste man den Container ja vorher sortieren...?</p>
<p>unique schrieb:</p>
<blockquote>
<p>Removes duplicate elements <strong>that are adjacent to each other</strong> in a specified range.</p>
</blockquote>
<p>Wenn schon mit Containern dann ist hier wohl ein std::set angebracht.</p>
<p>@Trööte: ja, macht ungeheuer Sinn dein Posting.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1330274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330274</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 22 Jul 2007 16:03:11 GMT</pubDate></item><item><title><![CDATA[Reply to 2 unterschiedliche CStrings vergleichen on Sun, 22 Jul 2007 16:11:14 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std::string str(&quot;def;jkl;opq;rst;uv;zz;&quot;);
std::string str_two(&quot;abc;def;uv;yxz;ut;uv;&quot;);

std::map&lt;std::string, std::size_t&gt; items;
for (std::size_t pos = str.find_first_of(';'); pos != std::string::npos; pos = str.find_first_of(';', pos + 1))
{
    std::string tmp(str.substr(0, pos));
    items[tmp] = 0;
    for (std::size_t pos_found = str_two.find_first_of(tmp); pos_found != std::string::npos; pos = str_two.find_first_of(tmp, pos_found + 1)) ++items[tmp];
    str.erase(0, pos);
}
</code></pre>
<p>Sowas?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1330280</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330280</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 22 Jul 2007 16:11:14 GMT</pubDate></item><item><title><![CDATA[Reply to 2 unterschiedliche CStrings vergleichen on Thu, 26 Jul 2007 14:59:53 GMT]]></title><description><![CDATA[<p>sorry, dein Beitrag hatte ich zu spät gesehen, daher sieht meine Lösung nicht so schön aus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> Aber es will nicht so wie ich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>also Ziel ist es, je nach Auftreten der Kürzel in Spalte astrProdStepProps[3] oder [4] den dahinterstehenden Mitarbeiter in der DB abzulegen, wenn das Kürzel, was übringens 2 bis 6 Buchstaben lang sein kann, nur in [3] steht soll eine 0 in die Zeile in der DB geschrieben werden, bei einem Eintrag in Zeile [4] eine 1 und wenn das Kürzel in [3] und [4] vorhanden ist, eine 2, jeweils als letzten Wert bei der entsprechenden VALUES Zeile.</p>
<pre><code class="language-cpp">// Copy Plan-Editors to a Help-Array for Both-Editors
	nStart = 0;
	if(!astrProdStepProps[3].IsEmpty())
	{
		astrProdStepProps[3] += strLimiter;
		while (-1 != (nEnd = astrProdStepProps[3].Find(strLimiter,nStart)))
		{				
			astrEmplPlanHelp[nIndexPlan++] = astrProdStepProps[3].Mid(nStart,nEnd - nStart);
			nStart = nEnd + strLimiter.GetLength();
		}
	}

	// Copy Is-Editors to a Help-Array for Both-Editors
	nStart = 0;
	if(!astrProdStepProps[4].IsEmpty())
	{
		astrProdStepProps[4] += strLimiter;
		while (-1 != (nEnd = astrProdStepProps[4].Find(strLimiter,nStart)))
		{				
			astrEmplIsHelp[nIndexIs++] = astrProdStepProps[4].Mid(nStart,nEnd - nStart);
			nStart = nEnd + strLimiter.GetLength();
		}
	}

	nStart = 0;
	if(!astrProdStepProps[3].IsEmpty())
	{
//		astrProdStepProps[3] += strLimiter;
		while (-1 != (nEnd = astrProdStepProps[3].Find(strLimiter,nStart)))
		{
            for (nIndex=0; nIndex &lt;= nIndexIs; nIndex++)
            {
                if (astrProdStepProps[3].Find(astrEmplIsHelp[nIndex], 0) != -1)
                {
                    astrProdStepProps[3].Delete(nStart,nEnd - nStart+1);
                    astrEmplBothHelp[nIndexBoth++] = astrEmplIsHelp[nIndex];
                }
            }				
			nStart = nEnd + strLimiter.GetLength();
		}
	}

	nStart = 0;
	if(!astrProdStepProps[4].IsEmpty())
	{
//		astrProdStepProps[4] += strLimiter;
		while (-1 != (nEnd = astrProdStepProps[4].Find(strLimiter,nStart)))
		{
            for (nIndex=0; nIndex &lt;= nIndexPlan; nIndex++)
            {
                if (astrProdStepProps[4].Find(astrEmplPlanHelp[nIndex], 0) != -1)
                    astrProdStepProps[4].Delete(nStart,nEnd - nStart+1);
            }				
			nStart = nEnd + strLimiter.GetLength();
		}
	}

    nStart = 0;
	if(astrProdStepProps[3].GetLength() &gt; 1)
	{
//		astrProdStepProps[3] += strLimiter;
		while (-1 != (nEnd = astrProdStepProps[3].Find(strLimiter,nStart)))
		{				
			// find the id of the qualification
			CString strIdPerson = sqlQuery.getPersonByToken(CSqlConnection::GetSqlDb(), astrProdStepProps[3].Mid(nStart,nEnd - nStart));

			// insert a new record for the employee
			strSqlStat =&quot;INSERT INTO tab_bearbeiterfertigungsschritt &quot;;
			strSqlStat += &quot;VALUES(&quot;+ astrProdStepProps[7] +&quot;, &quot; + strIdPerson + &quot;, 0);&quot;;

			// execute Insert
			pdbSql-&gt;ExecuteSQL(strSqlStat);  

			nStart = nEnd + strLimiter.GetLength();
		}
	}

    nStart = 0;
	if(astrProdStepProps[4].GetLength() &gt; 1)
	{
//		astrProdStepProps[4] += strLimiter;
		while (-1 != (nEnd = astrProdStepProps[4].Find(strLimiter,nStart)))
		{				
			// find the id of the qualification
			CString strIdPerson = sqlQuery.getPersonByToken(CSqlConnection::GetSqlDb(), astrProdStepProps[4].Mid(nStart,nEnd - nStart));

			// insert a new record for the employee
			strSqlStat =&quot;INSERT INTO tab_bearbeiterfertigungsschritt &quot;;
			strSqlStat += &quot;VALUES(&quot;+ astrProdStepProps[7] +&quot;, &quot; + strIdPerson + &quot;, 1);&quot;;

			// execute Insert
			pdbSql-&gt;ExecuteSQL(strSqlStat);  

			nStart = nEnd + strLimiter.GetLength();
		}
	}

    for (nIndex=0; nIndex &lt;= nIndexBoth; nIndex++)
    {
        // find the id of the qualification
        CString strIdPerson = sqlQuery.getPersonByToken(CSqlConnection::GetSqlDb(), astrEmplBothHelp[nIndex]);

        // insert a new record for the employee
		strSqlStat =&quot;INSERT INTO tab_bearbeiterfertigungsschritt &quot;;
		strSqlStat += &quot;VALUES(&quot;+ astrProdStepProps[7] +&quot;, &quot; + strIdPerson + &quot;, 2);&quot;;

		// execute Insert
		pdbSql-&gt;ExecuteSQL(strSqlStat);  
    }
</code></pre>
<p>Im strLimiter steht das &quot;;&quot;.</p>
<p>Sieht irgendwer einen logischen Fehler? Oder hätte einen Denkansatz? Ich habe mir das eigentlich nicht so schwer vorgestellt und so schwer kann das doch auch gar nicht sein ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333151</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333151</guid><dc:creator><![CDATA[Herbie]]></dc:creator><pubDate>Thu, 26 Jul 2007 14:59:53 GMT</pubDate></item><item><title><![CDATA[Reply to 2 unterschiedliche CStrings vergleichen on Thu, 26 Jul 2007 19:36:33 GMT]]></title><description><![CDATA[<p>Alter Schwede ... Herbie... dein Code ist echt schwer lesbar. Änder das mal</p>
<pre><code class="language-cpp">// hier kannst du bestimmt auch CStringArray benutzen
	CString PoductionStep[4];		// ehemals astrProdStepProps[3]
	CString PlanHelp[4];			// ehemals astrEmplPlanHelp[4] (was auch immer das bedeuten soll)
	CString IsHelp[4];				// ehemals astrEmplIsHelp
	CString Limiter = &quot;;&quot;;			// strLimiter
	//...

	// Copy Plan-Editors to a Help-Array for Both-Editors
	int Index = 0;
    int Start = 0;
	int End = 0; 

    if(!PoductionStep[3].IsEmpty())
    {
        PoductionStep[3] += Limiter;

		End = PoductionStep[3].Find(Limiter,nStart);

        while (End != -1) //(-1 != (nEnd = astrProdStepProps[3].Find(strLimiter,nStart)))
        {   
			Index++;        
			Temp[Index] = PoductionStep[3].Mid(Start,End - Start);
			Start = End + Limiter.GetLength();

			End = PoductionStep[3].Find(Limiter,nStart);
        }
    }

    // Copy Is-Editors to a Help-Array for Both-Editors
    Start = 0;
    if(!PoductionStep[4].IsEmpty())
    {
        PoductionStep[4] += strLimiter;
		End = PoductionStep[4].Find(Limiter, Start);

        while (End != -1)
        {      
			Index++;
            IsHelp[Index] = PoductionStep[4].Mid(Start,End - Start);
            Start = End + Limiter.GetLength();

			End = PoductionStep[4].Find(Limiter, Start);
        }
    }
	// ...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1333338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333338</guid><dc:creator><![CDATA[Leser]]></dc:creator><pubDate>Thu, 26 Jul 2007 19:36:33 GMT</pubDate></item></channel></rss>