<?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[char* verbinden]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bin dabei mir ein Programm zu schreiben, welches mir mehrere htm-Dateien für eine Bildergalerie erstellt. Das Problem is beim erstellen der Dateien soll immer eine Nummer im Dateinamen drin sein (z.B. Bild1.htm, Bild2.htm,...) und dadurch nehme ich char* um es zu realisieren, aber ich bekomme die Nummer leider nicht in den char* rein.</p>
<p>Hier mein Quelltext</p>
<pre><code class="language-cpp">void dateiSchreiben(string titel) {
char buff[80];
    int anzahl = 10;
    char* dateiname;
    for (int zaehler=1; zaehler&lt;=anzahl; zaehler++) {
      dateiname = &quot;C:/Bild&quot; + zaehler + &quot;.htm&quot;; // hier liegt der Fehler
//    char* dateiname = &quot;C:/Bild.htm&quot;;
	ofstream outfile(dateiname);
	if (outfile.good())
        outfile &lt;&lt; titel &lt;&lt; endl;
		for (int i = 0; i &lt;= 10; i++)
			outfile &lt;&lt; &quot;Das ist Zeile #&quot; &lt;&lt; (i + 1) &lt;&lt; endl;
	outfile.close();
    }
</code></pre>
<p>Für jedes bißchen Hilfe bin ich dankbar!<br />
Sascha</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/118831/char-verbinden</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 17:20:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/118831.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 24 Aug 2005 18:54:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to char* verbinden on Wed, 24 Aug 2005 18:54:27 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bin dabei mir ein Programm zu schreiben, welches mir mehrere htm-Dateien für eine Bildergalerie erstellt. Das Problem is beim erstellen der Dateien soll immer eine Nummer im Dateinamen drin sein (z.B. Bild1.htm, Bild2.htm,...) und dadurch nehme ich char* um es zu realisieren, aber ich bekomme die Nummer leider nicht in den char* rein.</p>
<p>Hier mein Quelltext</p>
<pre><code class="language-cpp">void dateiSchreiben(string titel) {
char buff[80];
    int anzahl = 10;
    char* dateiname;
    for (int zaehler=1; zaehler&lt;=anzahl; zaehler++) {
      dateiname = &quot;C:/Bild&quot; + zaehler + &quot;.htm&quot;; // hier liegt der Fehler
//    char* dateiname = &quot;C:/Bild.htm&quot;;
	ofstream outfile(dateiname);
	if (outfile.good())
        outfile &lt;&lt; titel &lt;&lt; endl;
		for (int i = 0; i &lt;= 10; i++)
			outfile &lt;&lt; &quot;Das ist Zeile #&quot; &lt;&lt; (i + 1) &lt;&lt; endl;
	outfile.close();
    }
</code></pre>
<p>Für jedes bißchen Hilfe bin ich dankbar!<br />
Sascha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/857797</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/857797</guid><dc:creator><![CDATA[sanehls.de]]></dc:creator><pubDate>Wed, 24 Aug 2005 18:54:27 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden on Wed, 24 Aug 2005 19:04:18 GMT]]></title><description><![CDATA[<p>char* ein pointer auf ein char. Du kannst keine int-Größen addieren.<br />
Ich würde es so machen:</p>
<pre><code class="language-cpp">stringstream dateiname;
for(int zaehler=1; zaehler&lt;anzahl; zaehler++){
    dateiname &lt;&lt;&quot;C:/Bild&quot; &lt;&lt;zaehler &lt;&lt;&quot;.htm&quot;
}
ofstream outfile(dateiname.str().c_str());
//...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/857801</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/857801</guid><dc:creator><![CDATA[Der Knirps]]></dc:creator><pubDate>Wed, 24 Aug 2005 19:04:18 GMT</pubDate></item><item><title><![CDATA[Reply to char* verbinden on Thu, 25 Aug 2005 08:48:29 GMT]]></title><description><![CDATA[<p>mit sprintf..</p>
<pre><code>#include &lt;stdio.h&gt;

.
.
.

void dateiSchreiben(string titel) 
{
    char buff[80];
    int anzahl = 10;
    char dateiname[255]; //es muss genug Platz sein :)
    for (int zaehler=1; zaehler&lt;=anzahl; zaehler++) 
    {
      //die stdio.h muss eingebunden werden
      sprintf( dateiname, &quot;C:/Bild%d.htm&quot;, zaehler );

      ofstream outfile(dateiname);

      if (outfile.good())
      {
        outfile &lt;&lt; titel &lt;&lt; endl;

        for (int i = 0; i &lt;= 10; i++)
          outfile &lt;&lt; &quot;Das ist Zeile #&quot; &lt;&lt; (i + 1) &lt;&lt; endl;
      }
      outfile.close();
    }
}
</code></pre>
<p>Hoffe ich konnte helfen.</p>
<p>PS: die Klammersetzung der &quot;outfile.good()&quot; abfrage war falsch..</p>
<p>Steffen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/858057</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/858057</guid><dc:creator><![CDATA[steffenbuechner.de.vu]]></dc:creator><pubDate>Thu, 25 Aug 2005 08:48:29 GMT</pubDate></item></channel></rss>