<?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[Error beim suchen in einer Datei]]></title><description><![CDATA[<p>Also ich hab folgendes Problem:<br />
An eine Funktion find wird ein CString übergeben und die soll in meiner Datei nach dem CString suchen.<br />
Doch in der Funktion bricht er, durch meinen try-Block ab und liefert mir &quot;ERROR!&quot;.<br />
Scgaut euch plz mal den folgenden COde an und die Fuktion find:</p>
<pre><code class="language-cpp">//In der Hauptdatei, bei Klick auf &quot;ShowInfo&quot;, das eine Info zu einem Ausgewähltem ListenElement zeigen soll

void CArchivarDlg::OnViewinfo() 
{
	HTREEITEM hItem=m_dir.GetSelectedItem();
	CInfoMovie dlg;
	int iCatchMsg;
	CString fullpath=m_dir.GetFullPath(hItem);

	try{
	if (hItem){
		MessageBox(&quot;hItem==true&quot;);
        if(find(fullpath))
		{
			MessageBox(&quot;find(fullpath)==true&quot;);
			//Code zur Variableneinlesung später hier hin
			dlg=load(fullpath,dlg);
		}
		else
		{
			MessageBox(&quot;find(fullpath)==false&quot;);
			iCatchMsg=MessageBox(&quot;No Info for this Item detected. Create a new one?&quot;,&quot;Create an Info&quot;,MB_YESNO);
			if(iCatchMsg)
			{
				MessageBox(fullpath,&quot;Path:&quot;);
				dlg.m_strPath=fullpath;//Problem: strPath is const char* und kann nicht fehlerfrei in CString umgewandelt werden
				//strcpy(dlg.m_strPath,m_dir.GetFullPath(hItem));
				MessageBox(dlg.m_strPath,&quot;Path in dlg&quot;);
				dlg.DoModal();
			}
			else if(!iCatchMsg) {}
		}
	}

    else
        MessageBox (&quot;No Item Selected...&quot;);
	}
	catch(...)
	{
		MessageBox(&quot;ERROR!&quot;);
		MessageBox(fullpath,&quot;Fullpath:&quot;);
	}
}

//Das hier ist in MovieInfo.cpp
bool find(CString path)
{
	bool temp;
	char* readpath=&quot;&quot;;
	int fsk=0;
	int howmuch=0;
	char* name=&quot;&quot;;
	char* format=&quot;&quot;;
	char* genre=&quot;&quot;;
	char* descr=&quot;&quot;;
	ifstream in(&quot;data.mio&quot;);
	if(!in){
		MessageBox(&quot;Die Datei konnte nicht zum lesen geoeffnet werden!&quot;,&quot;Error&quot;,IDOK||MB_ICONSTOP);
		return false;
	}
	do {
		in&gt;&gt;readpath;
		in&gt;&gt;fsk;
		in&gt;&gt;howmuch;
		in.getline(name,79,79);
		in.getline(format,79,79);
		in.getline(genre,79,79);
		in.getline(descr,79,79);
	}while((readpath!=path)&amp;&amp;(!in.eof()));

	in.close();

	if(temp)
		return true;
	else return false;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/55762/error-beim-suchen-in-einer-datei</link><generator>RSS for Node</generator><lastBuildDate>Tue, 02 Jun 2026 02:00:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/55762.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 19 Nov 2003 12:02:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Error beim suchen in einer Datei on Wed, 19 Nov 2003 12:02:56 GMT]]></title><description><![CDATA[<p>Also ich hab folgendes Problem:<br />
An eine Funktion find wird ein CString übergeben und die soll in meiner Datei nach dem CString suchen.<br />
Doch in der Funktion bricht er, durch meinen try-Block ab und liefert mir &quot;ERROR!&quot;.<br />
Scgaut euch plz mal den folgenden COde an und die Fuktion find:</p>
<pre><code class="language-cpp">//In der Hauptdatei, bei Klick auf &quot;ShowInfo&quot;, das eine Info zu einem Ausgewähltem ListenElement zeigen soll

void CArchivarDlg::OnViewinfo() 
{
	HTREEITEM hItem=m_dir.GetSelectedItem();
	CInfoMovie dlg;
	int iCatchMsg;
	CString fullpath=m_dir.GetFullPath(hItem);

	try{
	if (hItem){
		MessageBox(&quot;hItem==true&quot;);
        if(find(fullpath))
		{
			MessageBox(&quot;find(fullpath)==true&quot;);
			//Code zur Variableneinlesung später hier hin
			dlg=load(fullpath,dlg);
		}
		else
		{
			MessageBox(&quot;find(fullpath)==false&quot;);
			iCatchMsg=MessageBox(&quot;No Info for this Item detected. Create a new one?&quot;,&quot;Create an Info&quot;,MB_YESNO);
			if(iCatchMsg)
			{
				MessageBox(fullpath,&quot;Path:&quot;);
				dlg.m_strPath=fullpath;//Problem: strPath is const char* und kann nicht fehlerfrei in CString umgewandelt werden
				//strcpy(dlg.m_strPath,m_dir.GetFullPath(hItem));
				MessageBox(dlg.m_strPath,&quot;Path in dlg&quot;);
				dlg.DoModal();
			}
			else if(!iCatchMsg) {}
		}
	}

    else
        MessageBox (&quot;No Item Selected...&quot;);
	}
	catch(...)
	{
		MessageBox(&quot;ERROR!&quot;);
		MessageBox(fullpath,&quot;Fullpath:&quot;);
	}
}

//Das hier ist in MovieInfo.cpp
bool find(CString path)
{
	bool temp;
	char* readpath=&quot;&quot;;
	int fsk=0;
	int howmuch=0;
	char* name=&quot;&quot;;
	char* format=&quot;&quot;;
	char* genre=&quot;&quot;;
	char* descr=&quot;&quot;;
	ifstream in(&quot;data.mio&quot;);
	if(!in){
		MessageBox(&quot;Die Datei konnte nicht zum lesen geoeffnet werden!&quot;,&quot;Error&quot;,IDOK||MB_ICONSTOP);
		return false;
	}
	do {
		in&gt;&gt;readpath;
		in&gt;&gt;fsk;
		in&gt;&gt;howmuch;
		in.getline(name,79,79);
		in.getline(format,79,79);
		in.getline(genre,79,79);
		in.getline(descr,79,79);
	}while((readpath!=path)&amp;&amp;(!in.eof()));

	in.close();

	if(temp)
		return true;
	else return false;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/397664</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/397664</guid><dc:creator><![CDATA[Herr der Dinge]]></dc:creator><pubDate>Wed, 19 Nov 2003 12:02:56 GMT</pubDate></item><item><title><![CDATA[Reply to Error beim suchen in einer Datei on Wed, 19 Nov 2003 12:42:22 GMT]]></title><description><![CDATA[<p>was hat beim debuggen hitem fürn wert? und ich würd auch imma mit EOF aufs ende der datei prüfen, weil das auch ne fehlerquelle ist..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/397710</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/397710</guid><dc:creator><![CDATA[bellaschönchen]]></dc:creator><pubDate>Wed, 19 Nov 2003 12:42:22 GMT</pubDate></item><item><title><![CDATA[Reply to Error beim suchen in einer Datei on Wed, 19 Nov 2003 13:03:01 GMT]]></title><description><![CDATA[<p>Ähm also inzwischen hab ich das Problem gelöst, nämlich er mag anscheinend keine char* auslesen, deswegen hab ich halt jede Variable die ausgelesen wird auf nen Maximalwert gesetzt (sprich nen char Array draus gemacht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ).<br />
Ber jetzt hab ich ein zweites Problem: Wie kann man CStrings in char Arrays umwandeln?<br />
Weil ich arbeite ja mit der std IO und da kann man keine CStrings in eine Datei schreiben ohne dass dabei Fehler auftreten.<br />
&quot;Test&quot; wird da zu &quot;004323CCO&quot;.<br />
Kann man da eine Stringfuktion verwenden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/397739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/397739</guid><dc:creator><![CDATA[Herr der Dinge]]></dc:creator><pubDate>Wed, 19 Nov 2003 13:03:01 GMT</pubDate></item><item><title><![CDATA[Reply to Error beim suchen in einer Datei on Wed, 19 Nov 2003 13:14:36 GMT]]></title><description><![CDATA[<p>also ich würd mir in einer forschleife (dauer mit strName.GetLength()) jedes einzelne zeichen des CStrings mit GetAt(index) holen und ins chararray schreiben..ist aber nicht so richtig schnell..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/397760</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/397760</guid><dc:creator><![CDATA[bellaschönchen]]></dc:creator><pubDate>Wed, 19 Nov 2003 13:14:36 GMT</pubDate></item><item><title><![CDATA[Reply to Error beim suchen in einer Datei on Wed, 19 Nov 2003 15:11:54 GMT]]></title><description><![CDATA[<p>Naja bei dem Prog kommts nich so auf Geschwindigkeit an <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/397940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/397940</guid><dc:creator><![CDATA[Herr der Dinge]]></dc:creator><pubDate>Wed, 19 Nov 2003 15:11:54 GMT</pubDate></item></channel></rss>