<?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[Debug Assertion Failed]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe ein kleines Problem und weiß nicht wirklich weiter.<br />
Ich lese verschiedene Dateien ein.<br />
Diese haben eine unterschiedliche Namensgebung aber der Inhalt ist ähnlich.</p>
<pre><code>for (i = 0; i &lt; (int)strlen(strFilenamePrefix.c_str()) - 5; i++) {
      if (strncmp(&amp;strFilenamePrefix[i], &quot;.001.&quot;, 5) == 0) {
        strFilenamePrefix[i + 1] = '0';
        strFilenamePrefix[i + 2] = '0';
        strFilenamePrefix[i + 3] = '2';
      }
    }

    strcpy(strFileName1, (iniResultDir +  strFilenamePrefix +   strDateiFileSuffix).c_str());
	  ifstream ifss(strFileName1);

    if(ifss.is_open()){
      printf(&quot;file exists&quot;);

    }else{
     int j;
	  for (j = 0; j &lt; (int)strlen(strFilenamePrefix.c_str()) - 5; j++) {
		  if (strncmp(&amp;strFilenamePrefix[j], &quot;.002.&quot;, 5) == 0) {
			strFilenamePrefix[j + 1] = '0';
			strFilenamePrefix[j + 2] = '0';
			strFilenamePrefix[j + 3] = '1';
		  }
	  }

    strcpy(strFileName1, (iniResultDir +  strFilenamePrefix + strDateiFileSuffixsecond).c_str());
    fp1 = (FILE*)fopen(strFileName1, &quot;r&quot;);

    if ( fp1 == (FILE*)NULL )
    {
      sprintf(msg,&quot;\tERROR: File %s doesn't exists...\n&quot;, strFileName);
       printf(msg);
       writeLog(msg);
       return false;
    }
    fclose(fp1);
    }

    return true;
</code></pre>
<p>Wenn ich diesen code weglasse<br />
bekomme ich keine Fehlermeldung</p>
<p>for (j = 0; j &lt; (int)strlen(strFilenamePrefix.c_str()) - 5; j++) {<br />
if (strncmp(&amp;strFilenamePrefix[j], &quot;.002.&quot;, 5) == 0) {<br />
strFilenamePrefix[j + 1] = '0';<br />
strFilenamePrefix[j + 2] = '0';<br />
strFilenamePrefix[j + 3] = '1';<br />
}<br />
}</p>
<p>Aber Warum, dann stimmt der Name der zu suchenden Datei nicht.</p>
<p>Hoffe jemand weiß was.<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/305819/debug-assertion-failed</link><generator>RSS for Node</generator><lastBuildDate>Sat, 08 Aug 2026 14:29:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/305819.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 09 Jul 2012 13:44:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Debug Assertion Failed on Mon, 09 Jul 2012 13:44:31 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe ein kleines Problem und weiß nicht wirklich weiter.<br />
Ich lese verschiedene Dateien ein.<br />
Diese haben eine unterschiedliche Namensgebung aber der Inhalt ist ähnlich.</p>
<pre><code>for (i = 0; i &lt; (int)strlen(strFilenamePrefix.c_str()) - 5; i++) {
      if (strncmp(&amp;strFilenamePrefix[i], &quot;.001.&quot;, 5) == 0) {
        strFilenamePrefix[i + 1] = '0';
        strFilenamePrefix[i + 2] = '0';
        strFilenamePrefix[i + 3] = '2';
      }
    }

    strcpy(strFileName1, (iniResultDir +  strFilenamePrefix +   strDateiFileSuffix).c_str());
	  ifstream ifss(strFileName1);

    if(ifss.is_open()){
      printf(&quot;file exists&quot;);

    }else{
     int j;
	  for (j = 0; j &lt; (int)strlen(strFilenamePrefix.c_str()) - 5; j++) {
		  if (strncmp(&amp;strFilenamePrefix[j], &quot;.002.&quot;, 5) == 0) {
			strFilenamePrefix[j + 1] = '0';
			strFilenamePrefix[j + 2] = '0';
			strFilenamePrefix[j + 3] = '1';
		  }
	  }

    strcpy(strFileName1, (iniResultDir +  strFilenamePrefix + strDateiFileSuffixsecond).c_str());
    fp1 = (FILE*)fopen(strFileName1, &quot;r&quot;);

    if ( fp1 == (FILE*)NULL )
    {
      sprintf(msg,&quot;\tERROR: File %s doesn't exists...\n&quot;, strFileName);
       printf(msg);
       writeLog(msg);
       return false;
    }
    fclose(fp1);
    }

    return true;
</code></pre>
<p>Wenn ich diesen code weglasse<br />
bekomme ich keine Fehlermeldung</p>
<p>for (j = 0; j &lt; (int)strlen(strFilenamePrefix.c_str()) - 5; j++) {<br />
if (strncmp(&amp;strFilenamePrefix[j], &quot;.002.&quot;, 5) == 0) {<br />
strFilenamePrefix[j + 1] = '0';<br />
strFilenamePrefix[j + 2] = '0';<br />
strFilenamePrefix[j + 3] = '1';<br />
}<br />
}</p>
<p>Aber Warum, dann stimmt der Name der zu suchenden Datei nicht.</p>
<p>Hoffe jemand weiß was.<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231322</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231322</guid><dc:creator><![CDATA[campionissimo]]></dc:creator><pubDate>Mon, 09 Jul 2012 13:44:31 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Mon, 09 Jul 2012 14:03:21 GMT]]></title><description><![CDATA[<p>Du mischt C++ Strings mit C Stringfunktionen.<br />
Das kann nicht funktionieren. Statt strncmp verwende einfach string::compare, statt strlen einfach string::size, statt strcpy string::operator= und statt printf einfach std::cout.</p>
<p>Dann ist 1. dein Code viel viel kürzer und 2. viel viel fehlerfreier.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231334</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Mon, 09 Jul 2012 14:03:21 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Mon, 09 Jul 2012 15:18:58 GMT]]></title><description><![CDATA[<p>Wenn du sagst Fehlerfreier, wo sind die Fehler ?Ausser das ich c mit c++ mische ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231364</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231364</guid><dc:creator><![CDATA[campionissimo]]></dc:creator><pubDate>Mon, 09 Jul 2012 15:18:58 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Mon, 09 Jul 2012 15:46:08 GMT]]></title><description><![CDATA[<p>campionissimo schrieb:</p>
<blockquote>
<p>Wenn du sagst Fehlerfreier, wo sind die Fehler ?Ausser das ich c mit c++ mische ?</p>
</blockquote>
<p>Das <strong>ist</strong> der Fehler. Du denkst, das wäre harmlos, ist es aber nicht. Das sind wirklich schwerwiegendste Fehler, die du dadurch machst. Ein std::string ist eben kein nullterminiertes char-Array, noch nicht einmal ein einfacher Wrapper um eines. Du kannst nicht einfach Funktionen darauf loslassen, die blind annehmen, dass es sich um ein nullterminiertes char-Array handeln würde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231372</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231372</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 09 Jul 2012 15:46:08 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Mon, 09 Jul 2012 15:47:34 GMT]]></title><description><![CDATA[<p>campionissimo schrieb:</p>
<blockquote>
<p>Wenn du sagst Fehlerfreier, wo sind die Fehler ?Ausser das ich c mit c++ mische ?</p>
</blockquote>
<p>Das ist der Fehler.</p>
<p>zB könnte strncmp(&amp;strFilenamePrefix[i], &quot;.001.&quot;, 5) deine Debug Assertion auslösen. Weil man sowas mit std::string einfach nicht machen darf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231373</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231373</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Mon, 09 Jul 2012 15:47:34 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Mon, 09 Jul 2012 15:58:01 GMT]]></title><description><![CDATA[<p>aber dazu gibt es ja dann std::string::c_str()...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231379</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231379</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Mon, 09 Jul 2012 15:58:01 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 07:49:59 GMT]]></title><description><![CDATA[<p>Danke erstmal. Mir ist klar das ich das ganze mal einheitlich machen muss.<br />
Möchte aber trotzdem verstehen warum dieser Fehler auftritt.</p>
<pre><code>bool fileexist(char *filename)
{
    ifstream ifs(filename);

    if(ifs.is_open()){
      return true;

    }else{

    return false;
    }
}
andere Funktione:

strcpy(strFileName, (iniResultDir +  strFilenamePrefix + strDateiFileSuffix).c_str());
    bool erg = fileexist(strFileName);
    if (erg == false)
    {
        sprintf(msg,&quot;\tERROR: File %s doesn't exists...\n&quot;, strFileName);
        printf(msg);
        writeLog(msg);
        return false;
    }

  return true;
</code></pre>
<p>Das Programm geht schief durch das return true. Ich möchte aber verstehen warum.<br />
Auch wenn ich das Copy ändere und direkt zuweise geht es nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231536</guid><dc:creator><![CDATA[campionissimo]]></dc:creator><pubDate>Tue, 10 Jul 2012 07:49:59 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 07:56:31 GMT]]></title><description><![CDATA[<p>Wenn du ganz genau wissen willst, warum ein Programm wo abbricht, dann gib uns auch vollständigen Code. Jedenfalls ist mit Sicherheit nicht das return true Schuld, sondern du wirst dir vorher mit deinen Aktionen den Stack zerschossen haben. Wo genau, dafür müsste man auch genau wissen, wie dein Programm aussieht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231539</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231539</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 10 Jul 2012 07:56:31 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 08:05:10 GMT]]></title><description><![CDATA[<p>Hier wäre der relevante Teil:</p>
<pre><code>bool fileexist(char *filename)
{
    ifstream ifs(filename);

    if(ifs.is_open()){
      return true;

    }else{

    return false;
    }
}

bool existsAllFiles (string strFilenamePrefix)
{

  char strFileName[MAX_PATH];
  FILE* fp;

    strcpy(strFileName, (iniSceneDir + strFilenamePrefix + strFirstFileSuffix).c_str());
    fp = (FILE*)fopen(strFileName, &quot;r&quot;);
    if ( fp == (FILE*)NULL )
    {
        sprintf(msg,&quot;\tERROR: File %s doesn't exists...\n&quot;, strFileName);
        printf(msg);
        writeLog(msg);
        return false;
    }
    fclose(fp);
    strcpy(strFileName, (iniSceneDir + strFilenamePrefix + strSecondFileSuffix).c_str());
    fp = (FILE*)fopen(strFileName, &quot;r&quot;);
    if ( fp == (FILE*)NULL )
    {
        sprintf(msg,&quot;\tERROR: File %s doesn't exists...\n&quot;, strFileName);
        printf(msg);
        writeLog(msg);
        return false;
    }
    fclose(fp);

    string str = strFilenamePrefix;
    string str2 = &quot;.001.&quot;;
    str.replace(21,5,str2);
    strFilenamePrefix = str;

    strcpy(strFileName, (iniResultDir +  strFilenamePrefix + strthirdFileSuffix).c_str());

    ifstream ifs(strFileName);

    if(ifs.is_open()){
      printf(&quot;file exists&quot;);

    }else{

      FILE* create; 
      create = fopen(strFileName,&quot;w&quot;); 

      sprintf(msg,&quot;\tWARNING: Emty File %s is created...\n&quot;, strFileName);
	    printf(msg);
	    writeLog(msg);
      fclose(create);
    }

    strcpy(strFileName, (iniResultDir +  strFilenamePrefix + strforthFileSuffix).c_str());
    bool erg = fileexist(strFileName);
    if (erg == false)
    {
        sprintf(msg,&quot;\tERROR: File %s doesn't exists...\n&quot;, strFileName);
        printf(msg);
        writeLog(msg);
        return false;
    }

  return true;
}
</code></pre>
<p>Ja der Stack kann natürlich zerschossen werden, aber warum.<br />
Das Programm überprüft die verschiedenen Datei ob diese existieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231542</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231542</guid><dc:creator><![CDATA[campionissimo]]></dc:creator><pubDate>Tue, 10 Jul 2012 08:05:10 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 08:16:22 GMT]]></title><description><![CDATA[<p>Du willst offensichtlich gar nicht wissen, was das Problem ist. Warum fragst du dann noch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231545</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231545</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 10 Jul 2012 08:16:22 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 08:18:16 GMT]]></title><description><![CDATA[<p>Wie groß ist msg?</p>
<p>Aber bitte bitte bitte, schmeiss den Code weg und mach es ordentlich.<br />
Da hast du zB eine Bibliothek für Filesystem Zugriff: <a href="http://www.boost.org/doc/libs/1_50_0/libs/filesystem/doc/index.htm" rel="nofollow">http://www.boost.org/doc/libs/1_50_0/libs/filesystem/doc/index.htm</a></p>
<p>Und misch bitte bitte bitte nicht C und C++. Da kommt nur blödsinn raus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231546</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Tue, 10 Jul 2012 08:18:16 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 08:20:43 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ja ihr sagtet das ich ein mischmasch habe. Das ist mir klar.<br />
Aber trotzdem möchte ich dennoch wissen warum es schief geht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231548</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231548</guid><dc:creator><![CDATA[campionissimo]]></dc:creator><pubDate>Tue, 10 Jul 2012 08:20:43 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 08:24:22 GMT]]></title><description><![CDATA[<p>msg ist nur eine Ausgbae von</p>
<p>die habe ich auf char msg[255]</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231549</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231549</guid><dc:creator><![CDATA[campionissimo]]></dc:creator><pubDate>Tue, 10 Jul 2012 08:24:22 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 09:25:44 GMT]]></title><description><![CDATA[<p>campionissimo schrieb:</p>
<blockquote>
<p>ja ihr sagtet das ich ein mischmasch habe. Das ist mir klar.<br />
Aber trotzdem möchte ich dennoch wissen warum es schief geht.</p>
</blockquote>
<p>Stell dir einen Automechaniker vor. Jemand kommt mit einer selbstgebaute Kiste daher wo 100 millionen unterschiedliche Teile drin sind, sogar der Motor ist irgendwie aus anderen Teilen zusammengebaut.</p>
<p>Und der Automechaniker soll jetzt rausfinden warum das Auto manchmal nicht anspringt.</p>
<p>Die Lösung des Mechanikers ist: kauf dir ein ordentliches Auto.</p>
<p>Selbes hier.</p>
<p>uU ist msg mit 255 Zeichen zu kurz - je nachdem wie lange der Pfadname ist. uU ist writeLog fehlerhaft. Oder der Fehler liegt ganz woanders.</p>
<p>Das was du machen willst funktioniert so halt einfach nicht. Du musst den Code wegschmeissen und es richtig machen. Oder benutz einen Debugger und schau nach was genau den Fehler produziert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231571</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231571</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Tue, 10 Jul 2012 09:25:44 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 09:34:28 GMT]]></title><description><![CDATA[<p>das msg hab ich schon vergrößert. Ist nicht der Fehler.<br />
Und debuggn geht auch nicht wirklich.<br />
Hab die Namen überprüft. Der debugger geht genau bis zu return true und dann der assertion failed<br />
expression stream != NULL<br />
line 27.<br />
Die line kann nicht der Grund sein, da hier die definition ist.<br />
Keine ahnung, Möchte eigentlich nur wissen wo der Fehler auftritt. Auch wenn der code nicht gut ist da ich c und c++ mische</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231576</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231576</guid><dc:creator><![CDATA[campionissimo]]></dc:creator><pubDate>Tue, 10 Jul 2012 09:34:28 GMT</pubDate></item><item><title><![CDATA[Reply to Debug Assertion Failed on Tue, 10 Jul 2012 09:38:44 GMT]]></title><description><![CDATA[<p>Shade Of Mine schrieb:</p>
<blockquote>
<p>Stell dir einen Automechaniker vor. Jemand kommt mit <strong>einem Foto von</strong> einer selbstgebaute Kiste daher wo 100 millionen unterschiedliche Teile drin sind, sogar der Motor ist irgendwie aus anderen Teilen zusammengebaut.</p>
</blockquote>
<p>FTFY</p>
<p>@Threadersteller: Zum dritten Mal: Wenn du genaue Antworten willst, dann zeig auch den kompletten Code. Zu deinen kurzen Ausschnitten kann man keine genauen Analysen geben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231577</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231577</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 10 Jul 2012 09:38:44 GMT</pubDate></item></channel></rss>