<?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[Der Inhalt eines Streams in einer Variable speichern]]></title><description><![CDATA[<p>Guten Abend zusammen.</p>
<p>Der Inhalt des index.txt wird schön in die Datei test.txt geschrieben.<br />
Gleichzeitig möchte ich diesen Inhalt in einer Variable (buffer) speichern für eine spätere weitere Verwendung.<br />
Irgendwas scheint nicht zu funktionieren, denn die MessageBox zeigt mir nur komische Zeichen an.</p>
<p>Grüsse und herzlichen Dank,<br />
Sotares</p>
<pre><code>HINTERNET Initialize,Connection,File;
			DWORD dwBytes;
			char ch;
			FILE*     fFile; 
			char buffer;

			/*initialize the wininet library*/
			Initialize = InternetOpen(&quot;HTTPGET&quot;,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);

			/*connect to the server*/
			Connection = InternetConnect(Initialize,&quot;localhost&quot;,INTERNET_DEFAULT_HTTP_PORT,
			NULL,NULL,INTERNET_SERVICE_HTTP,0,0);

			/*open up an HTTP request*/
			File = HttpOpenRequest(Connection,NULL,&quot;/notewriter/index.txt&quot;,NULL,NULL,NULL,0,0);

			if(HttpSendRequest(File,NULL,0,NULL,0))
			{
				fFile = fopen(&quot;c:\\test.txt&quot;, &quot;w+b&quot;);
				while(InternetReadFile(File,&amp;ch,1,&amp;dwBytes))
				{
				if(dwBytes != 1)break;
				putchar(ch);
				buffer += ch;
				fwrite(&amp;ch, 1, dwBytes, fFile); 
				}
				fclose(fFile);
			}

			/*close file , terminate server connection and
			deinitialize the wininet library*/
			InternetCloseHandle(File);
			InternetCloseHandle(Connection);
			InternetCloseHandle(Initialize);

			MessageBox(NULL, &amp;buffer, &quot;&quot;,0);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/167196/der-inhalt-eines-streams-in-einer-variable-speichern</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 15:43:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/167196.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 07 Dec 2006 18:29:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Der Inhalt eines Streams in einer Variable speichern on Thu, 07 Dec 2006 18:29:45 GMT]]></title><description><![CDATA[<p>Guten Abend zusammen.</p>
<p>Der Inhalt des index.txt wird schön in die Datei test.txt geschrieben.<br />
Gleichzeitig möchte ich diesen Inhalt in einer Variable (buffer) speichern für eine spätere weitere Verwendung.<br />
Irgendwas scheint nicht zu funktionieren, denn die MessageBox zeigt mir nur komische Zeichen an.</p>
<p>Grüsse und herzlichen Dank,<br />
Sotares</p>
<pre><code>HINTERNET Initialize,Connection,File;
			DWORD dwBytes;
			char ch;
			FILE*     fFile; 
			char buffer;

			/*initialize the wininet library*/
			Initialize = InternetOpen(&quot;HTTPGET&quot;,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);

			/*connect to the server*/
			Connection = InternetConnect(Initialize,&quot;localhost&quot;,INTERNET_DEFAULT_HTTP_PORT,
			NULL,NULL,INTERNET_SERVICE_HTTP,0,0);

			/*open up an HTTP request*/
			File = HttpOpenRequest(Connection,NULL,&quot;/notewriter/index.txt&quot;,NULL,NULL,NULL,0,0);

			if(HttpSendRequest(File,NULL,0,NULL,0))
			{
				fFile = fopen(&quot;c:\\test.txt&quot;, &quot;w+b&quot;);
				while(InternetReadFile(File,&amp;ch,1,&amp;dwBytes))
				{
				if(dwBytes != 1)break;
				putchar(ch);
				buffer += ch;
				fwrite(&amp;ch, 1, dwBytes, fFile); 
				}
				fclose(fFile);
			}

			/*close file , terminate server connection and
			deinitialize the wininet library*/
			InternetCloseHandle(File);
			InternetCloseHandle(Connection);
			InternetCloseHandle(Initialize);

			MessageBox(NULL, &amp;buffer, &quot;&quot;,0);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1188536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1188536</guid><dc:creator><![CDATA[Sotares]]></dc:creator><pubDate>Thu, 07 Dec 2006 18:29:45 GMT</pubDate></item><item><title><![CDATA[Reply to Der Inhalt eines Streams in einer Variable speichern on Thu, 07 Dec 2006 18:37:49 GMT]]></title><description><![CDATA[<p>Hmm, besteht dein Buffer nur aus einem char ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1188544</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1188544</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Thu, 07 Dec 2006 18:37:49 GMT</pubDate></item><item><title><![CDATA[Reply to Der Inhalt eines Streams in einer Variable speichern on Thu, 07 Dec 2006 20:46:30 GMT]]></title><description><![CDATA[<p>geeky schrieb:</p>
<blockquote>
<p>Hmm, besteht dein Buffer nur aus einem char ?</p>
</blockquote>
<p>Nein, dies war ein Fehler.</p>
<p>Ich habe nun die Lösung gefunden.</p>
<p>Sotares</p>
<pre><code>static char buffer[]={0};
int iLenght=0;

...
...

while(InternetReadFile(File,&amp;ch,1,&amp;dwBytes))
                {
                if(dwBytes != 1)break;
                putchar(ch);
                buffer[iLenght++] = ch;
				fwrite(&amp;ch, 1, dwBytes, fFile);
                }
                fclose(fFile);

...
...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1188638</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1188638</guid><dc:creator><![CDATA[Sotares]]></dc:creator><pubDate>Thu, 07 Dec 2006 20:46:30 GMT</pubDate></item><item><title><![CDATA[Reply to Der Inhalt eines Streams in einer Variable speichern on Thu, 07 Dec 2006 23:10:29 GMT]]></title><description><![CDATA[<p>InternetReadFile mit einer Puffergröße von 1 ist ganz schön ineffizient.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1188668</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1188668</guid><dc:creator><![CDATA[cpu]]></dc:creator><pubDate>Thu, 07 Dec 2006 23:10:29 GMT</pubDate></item><item><title><![CDATA[Reply to Der Inhalt eines Streams in einer Variable speichern on Fri, 08 Dec 2006 00:19:41 GMT]]></title><description><![CDATA[<p>Besser: so ziemlich jede &quot;read&quot; oder &quot;write&quot; Funktion mit einer Puffergrösse von einem Byte ist ziemlich ineffizient.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1188681</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1188681</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 08 Dec 2006 00:19:41 GMT</pubDate></item></channel></rss>