<?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[fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ?]]></title><description><![CDATA[<p>Also ich schreibe gerade eine Funktion write(const char* filename, container c)</p>
<p>ich öffne (und erzeuge) die Datei mit fopen(filename,&quot;w&quot;)</p>
<p>wenn ich als filename &quot;test&quot; übergebe bekomme ich beim ausführen die Fehlerausgabe Segmentation fault.</p>
<p>wenn ich aber &quot;test.txt&quot; übergebe funktioniert es.</p>
<p>in meiner Funktion read (const char* filename) benutze ich auch fopen(filename,&quot;r&quot;) da funktioniert es auch ohne .txt Endung.</p>
<p>Ist das normal so ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/218000/fopen-filename-quot-w-quot-funktioniert-nicht-für-dateien-ohne-endung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 04:13:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/218000.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 14 Jul 2008 17:12:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 17:12:43 GMT]]></title><description><![CDATA[<p>Also ich schreibe gerade eine Funktion write(const char* filename, container c)</p>
<p>ich öffne (und erzeuge) die Datei mit fopen(filename,&quot;w&quot;)</p>
<p>wenn ich als filename &quot;test&quot; übergebe bekomme ich beim ausführen die Fehlerausgabe Segmentation fault.</p>
<p>wenn ich aber &quot;test.txt&quot; übergebe funktioniert es.</p>
<p>in meiner Funktion read (const char* filename) benutze ich auch fopen(filename,&quot;r&quot;) da funktioniert es auch ohne .txt Endung.</p>
<p>Ist das normal so ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547255</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547255</guid><dc:creator><![CDATA[KA51O]]></dc:creator><pubDate>Mon, 14 Jul 2008 17:12:43 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 17:16:45 GMT]]></title><description><![CDATA[<p>Wie heisst den das File? test oder test.txt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547261</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 14 Jul 2008 17:16:45 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 17:19:17 GMT]]></title><description><![CDATA[<p>die Datei muss vorher nicht vorhanden sein und sollte gegebenenfalls von fopen angelegt werden.</p>
<p>es sollte für beides test und test.txt funktionieren</p>
<p>bei test.txt legt er sie selbstständig an bei test aber nicht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547262</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547262</guid><dc:creator><![CDATA[KA51O]]></dc:creator><pubDate>Mon, 14 Jul 2008 17:19:17 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 17:36:37 GMT]]></title><description><![CDATA[<p>Zeig mal den Code her.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547271</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547271</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 14 Jul 2008 17:36:37 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 17:41:42 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void SampleBagIO::writeToLibSvmFile(const char* filename, SampleBag samplebag)
{
	if(filename != &quot;&quot;)
	{
		FILE *fp = fopen(filename,&quot;w&quot;);
		ostringstream outputfile;
		int featureSize = samplebag.getSample(0).getFeature().getSize();

		for (int i = 0; i &lt; samplebag.getSize(); i++)
		{
			int featureSize = samplebag.getSample(i).getFeature().getSize();
			outputfile &lt;&lt; samplebag.getSample(i).getClassNumber();
			for (int j = 0; j &lt; featureSize; j++)
			{

				outputfile &lt;&lt; &quot; &quot; &lt;&lt; j+1 &lt;&lt; &quot;:&quot; &lt;&lt; samplebag.getSample(i).getFeature().getValue(j);

			}
			outputfile &lt;&lt; endl;
			string str = outputfile.str();
			const char *c = str.c_str();
			fputs(c, fp);
		}
		fclose(fp);
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1547278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547278</guid><dc:creator><![CDATA[KA51O]]></dc:creator><pubDate>Mon, 14 Jul 2008 17:41:42 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 17:47:10 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">FILE* file =  std::fopen (&quot;test&quot;,&quot;w&quot;);
	 fputs (&quot;2&quot;,file);
	 fclose (file);
</code></pre>
<p>Das funktioniert bei mir. Eventuell stimmt was mit den Rechten nicht.</p>
<p>Aber warum machst du das so kompliziert? Wenn du sowieso schon mit ostringstream arbeitest, kannst du doch auch gleich einen ofstream nehmen, anstatt das so komisch zu verrenken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547281</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547281</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 14 Jul 2008 17:47:10 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 17:49:51 GMT]]></title><description><![CDATA[<p>soweit ich mich entsinne hab ich das probiert aber bei ofstream muss die datei vorhanden sein und kann nicht beim initialisieren erzeugt werden.</p>
<p>correct me if i'm wrong</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547283</guid><dc:creator><![CDATA[KA51O]]></dc:creator><pubDate>Mon, 14 Jul 2008 17:49:51 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 18:02:09 GMT]]></title><description><![CDATA[<p>Geht genauso.</p>
<p><a href="http://www.cplusplus.com/reference/iostream/ofstream/" rel="nofollow">http://www.cplusplus.com/reference/iostream/ofstream/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547286</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547286</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 14 Jul 2008 18:02:09 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 18:10:41 GMT]]></title><description><![CDATA[<p>Hmm.. komisch, wo sind die &quot;Das ist ein C++ forum nicht ANSI C forun&quot; kommentare</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547291</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547291</guid><dc:creator><![CDATA[ANSICException]]></dc:creator><pubDate>Mon, 14 Jul 2008 18:10:41 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 18:12:13 GMT]]></title><description><![CDATA[<p>ok danke probiers gleich nochmal.</p>
<p>Bin im Moment leider schon beim nächsten Problem ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547293</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547293</guid><dc:creator><![CDATA[KA51O]]></dc:creator><pubDate>Mon, 14 Jul 2008 18:12:13 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 18:37:53 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void SampleBagIO::writeToLibSvmFile(const char* filename, SampleBag samplebag)
{
	if(filename != &quot;&quot;)
	{
		ofstream outputfile;
		outputfile.open(filename);

		for (int i = 0; i &lt; samplebag.getSize(); i++)
		{
			int featureSize = samplebag.getSample(i).getFeature().getSize();
			outputfile &lt;&lt; samplebag.getSample(i).getClassNumber();
			for (int j = 0; j &lt; featureSize; j++)outputfile &lt;&lt; &quot; &quot; &lt;&lt; j+1 &lt;&lt; &quot;:&quot; &lt;&lt; samplebag.getSample(i).getFeature().getValue(j);		
			outputfile &lt;&lt; endl;
		}
		outputfile.close();
	}
}
</code></pre>
<p>sieht echt besser aus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Danke</p>
<p>trotzdem bin ich noch nicht ganz zufrieden. Die angelegte Datei hat immer die Endung .txt</p>
<p>ich finde doch noch das haar in der suppe ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547305</guid><dc:creator><![CDATA[KA51O]]></dc:creator><pubDate>Mon, 14 Jul 2008 18:37:53 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Mon, 14 Jul 2008 21:52:16 GMT]]></title><description><![CDATA[<p>if(filename != &quot;&quot;)</p>
<p>ist immer wahr.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547395</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Mon, 14 Jul 2008 21:52:16 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Tue, 15 Jul 2008 03:04:13 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if(!strcmp(filename,&quot;&quot;)){
...
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1547447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547447</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Tue, 15 Jul 2008 03:04:13 GMT</pubDate></item><item><title><![CDATA[Reply to fopen(filename,&amp;quot;w&amp;quot;) funktioniert nicht für Dateien ohne Endung ? on Tue, 15 Jul 2008 16:20:36 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19249">@KA51O</a>:<br />
Was übergibst du den?<br />
ofstream erzeugt dir eine Datei, genauso, wie du sie öffnen willst. Wenn du &quot;hmm&quot; übergibst, dann erstellt er dir eine Datei, die genau &quot;hmm&quot; heisst, ohne was anderes.</p>
<p>BorisDieKlinge schrieb:</p>
<blockquote>
<pre><code class="language-cpp">if(!strcmp(filename,&quot;&quot;)){
...
}
</code></pre>
</blockquote>
<p>Oder gleich std::string und std::string::c_str benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1547773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1547773</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Tue, 15 Jul 2008 16:20:36 GMT</pubDate></item></channel></rss>