<?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[habe dringendes Problem bei E&#x2F;A Funktionen!]]></title><description><![CDATA[<p>erstmal mein prog:</p>
<pre><code class="language-cpp">#include &lt;sys/types.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;arpa/inet.h&gt;
#include &lt;unistd.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string&gt;
#include&lt;iostream&gt;
#include&lt;errno.h&gt;
#include&lt;fcntl.h&gt;
#include&lt;sys/stat.h&gt;

using namespace std;

class kontaktlist
{
public:
char *puffer;

	kontaktlist(char* begin,char *neu) {
		readlist(begin);
 		cout&lt;&lt;&quot;Fehler&quot;&lt;&lt;endl;
     		writelist(begin,neu);
	}

	void readlist (char *begin){
	        string end=&quot;.c&quot;;
	        string all = begin + end;
	  	char *next = &amp;all.at(0);
	    	  cout&lt;&lt;next&lt;&lt;endl;
	  	FILE *pfile = fopen(next,&quot;a+&quot;);
			if(pfile==NULL)
			{
		   	   	cout&lt;&lt;&quot;Error: &quot;&lt;&lt;strerror(errno)&lt;&lt;endl;
		   	}else{
	  	   	   fseek(pfile,0,SEEK_END);
	  	   	   int size = ftell(pfile);
	  	   	   rewind(pfile);
		     		cout&lt;&lt;size&lt;&lt;endl;
	  	   	   fread(puffer,1,size,pfile);
	  	  	   puffer[size] = '\0';
	    	     		cout&lt;&lt;&quot;Datei &quot;&lt;&lt;next&lt;&lt;&quot; gelesen&quot;&lt;&lt;endl;
            	     		cout&lt;&lt;puffer&lt;&lt;endl;
		   	   	cout&lt;&lt;&quot;HUHU&quot;&lt;&lt;endl;
		   	   	fflush(pfile);
			}
			fclose(pfile);
	}

	void writelist(char *begin_w,string neu){
	    string end_w =&quot;.c&quot;;
	    string all_w = begin_w + end_w;
	    char *next_w = &amp;all_w.at(0);

	       cout&lt;&lt;next_w&lt;&lt;endl;
	    FILE *pfile_w = fopen(next_w,&quot;a+&quot;);
		if(pfile_w==NULL)
		{
	              cout&lt;&lt;&quot;Error: &quot;&lt;&lt;strerror(errno)&lt;&lt;endl; 
	            fclose(pfile_w);
		}else{
		    fseek(pfile_w,0,SEEK_END);
 	            int size_w = ftell(pfile_w);
		    rewind(pfile_w);
		    neu= neu + ';';
		    char *neu_w = &amp;neu.at(0);
	  	    fwrite(neu_w,1,size_w,pfile_w);
		      cout&lt;&lt;&quot;Datei &quot;&lt;&lt;next_w&lt;&lt;&quot; neugeschrieben&quot;&lt;&lt;endl;
		      cout&lt;&lt;neu_w&lt;&lt;endl;
		    fclose(pfile_w);
		}
	}
};
 int main(){
    kontaktlist test(&quot;marko&quot;,&quot;buh&quot;);
    return 0;
 }
</code></pre>
<p>eine besonderes augenmerk dabei auf writelist:<br />
die Methode bekommt einen string (als char zeiger) wo der Dateiname steht und einen wo der neue Inhalt steht.<br />
er hängt an Dateinamen das Dateiformat an und öffnet diese.<br />
dann hängt er an dem Inhalt ,der hinzukommen soll ein ; ran und schreibt das in die Datei (und hängt es an dem vorherigen Inhalt an). Dann schließt das Programm.<br />
Nun habe ich folgendes Problenm: wenn die Datei leer ist in die Writelist was reinschreiben soll, weigert er sich. Wie ist dieses Problem zu lösen?<br />
ps: es soll unter Linux laufen undFile zeiger benutzen!</p>
<p>thx schonmal für help</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/136045/habe-dringendes-problem-bei-e-a-funktionen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 06:25:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/136045.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Feb 2006 20:09:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to habe dringendes Problem bei E&#x2F;A Funktionen! on Mon, 06 Feb 2006 20:09:18 GMT]]></title><description><![CDATA[<p>erstmal mein prog:</p>
<pre><code class="language-cpp">#include &lt;sys/types.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;arpa/inet.h&gt;
#include &lt;unistd.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string&gt;
#include&lt;iostream&gt;
#include&lt;errno.h&gt;
#include&lt;fcntl.h&gt;
#include&lt;sys/stat.h&gt;

using namespace std;

class kontaktlist
{
public:
char *puffer;

	kontaktlist(char* begin,char *neu) {
		readlist(begin);
 		cout&lt;&lt;&quot;Fehler&quot;&lt;&lt;endl;
     		writelist(begin,neu);
	}

	void readlist (char *begin){
	        string end=&quot;.c&quot;;
	        string all = begin + end;
	  	char *next = &amp;all.at(0);
	    	  cout&lt;&lt;next&lt;&lt;endl;
	  	FILE *pfile = fopen(next,&quot;a+&quot;);
			if(pfile==NULL)
			{
		   	   	cout&lt;&lt;&quot;Error: &quot;&lt;&lt;strerror(errno)&lt;&lt;endl;
		   	}else{
	  	   	   fseek(pfile,0,SEEK_END);
	  	   	   int size = ftell(pfile);
	  	   	   rewind(pfile);
		     		cout&lt;&lt;size&lt;&lt;endl;
	  	   	   fread(puffer,1,size,pfile);
	  	  	   puffer[size] = '\0';
	    	     		cout&lt;&lt;&quot;Datei &quot;&lt;&lt;next&lt;&lt;&quot; gelesen&quot;&lt;&lt;endl;
            	     		cout&lt;&lt;puffer&lt;&lt;endl;
		   	   	cout&lt;&lt;&quot;HUHU&quot;&lt;&lt;endl;
		   	   	fflush(pfile);
			}
			fclose(pfile);
	}

	void writelist(char *begin_w,string neu){
	    string end_w =&quot;.c&quot;;
	    string all_w = begin_w + end_w;
	    char *next_w = &amp;all_w.at(0);

	       cout&lt;&lt;next_w&lt;&lt;endl;
	    FILE *pfile_w = fopen(next_w,&quot;a+&quot;);
		if(pfile_w==NULL)
		{
	              cout&lt;&lt;&quot;Error: &quot;&lt;&lt;strerror(errno)&lt;&lt;endl; 
	            fclose(pfile_w);
		}else{
		    fseek(pfile_w,0,SEEK_END);
 	            int size_w = ftell(pfile_w);
		    rewind(pfile_w);
		    neu= neu + ';';
		    char *neu_w = &amp;neu.at(0);
	  	    fwrite(neu_w,1,size_w,pfile_w);
		      cout&lt;&lt;&quot;Datei &quot;&lt;&lt;next_w&lt;&lt;&quot; neugeschrieben&quot;&lt;&lt;endl;
		      cout&lt;&lt;neu_w&lt;&lt;endl;
		    fclose(pfile_w);
		}
	}
};
 int main(){
    kontaktlist test(&quot;marko&quot;,&quot;buh&quot;);
    return 0;
 }
</code></pre>
<p>eine besonderes augenmerk dabei auf writelist:<br />
die Methode bekommt einen string (als char zeiger) wo der Dateiname steht und einen wo der neue Inhalt steht.<br />
er hängt an Dateinamen das Dateiformat an und öffnet diese.<br />
dann hängt er an dem Inhalt ,der hinzukommen soll ein ; ran und schreibt das in die Datei (und hängt es an dem vorherigen Inhalt an). Dann schließt das Programm.<br />
Nun habe ich folgendes Problenm: wenn die Datei leer ist in die Writelist was reinschreiben soll, weigert er sich. Wie ist dieses Problem zu lösen?<br />
ps: es soll unter Linux laufen undFile zeiger benutzen!</p>
<p>thx schonmal für help</p>
]]></description><link>https://www.c-plusplus.net/forum/post/988032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988032</guid><dc:creator><![CDATA[DanteMcRayne]]></dc:creator><pubDate>Mon, 06 Feb 2006 20:09:18 GMT</pubDate></item><item><title><![CDATA[Reply to habe dringendes Problem bei E&#x2F;A Funktionen! on Tue, 07 Feb 2006 07:55:59 GMT]]></title><description><![CDATA[<p>Mein Tip - lasse das char*-Kuddelmuddel bleiben und verwende stattdessen durchgehend strings.</p>
<p>Ansonsten: Was für eine Fehlermeldung spuckt denn der strerror()-Aufruf aus?</p>
<p>PS: Und dein Gegurke in der Datei sieht auch grausam aus. Schau dir doch einfach mal die Parameter der Funktion <a href="http://man.cx/fwrite" rel="nofollow">man: fwrite</a>() an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/988185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/988185</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 07 Feb 2006 07:55:59 GMT</pubDate></item></channel></rss>