<?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[schnelle Hilfe bei Bibliothek benötigt]]></title><description><![CDATA[<p>Ich habe folgendes Program:</p>
<pre><code class="language-cpp">#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string&gt;
#include&lt;iostream&gt;
 #include&lt;fstream&gt;
#include&lt;vector&gt;

using namespace std;

class kontaktlist
{
public:
ifstream is;
ofstream off;

	kontaktlist(char* begin,char *neu) {
 		readlist(begin);
   		writelist(begin,neu);
  		clearlist(begin,neu);
	}

	vector&lt;string&gt; readlist (char *begin){
	        vector&lt;string&gt;foo_r;
	        string end=&quot;.c&quot;;
	        string all = begin + end;
	  	char *next_r = &amp;all.at(0);
		is.open(next_r,ios::in);
		  if (is.is_open())
		  {
			is.seekg (0, ios::end);
  		  	int length_r = 0;
		  	length_r = is.tellg();
  		  	is.seekg (0, ios::beg);
		  	char *buffer_r = new char[length_r];
			is.read (buffer_r,length_r);
		  	is.close();
			foo_r.push_back(buffer_r);
			return (foo_r);
		  	}else{
			is.close();
			off.open(next_r,ios::out|ios::app);
			off&lt;&lt;&quot;&quot;;
			off.close();
			return (foo_r);
		}
	}

	void writelist (char *begin,string neu){
		string end=&quot;.c&quot;;
	        string all = begin + end;
	  	char *next_w = &amp;all.at(0);
	    	is.open(next_w,ios::in);
		if (is.is_open())
  		{
			is.close();
			off.open(next_w,ios::out|ios::app);
    			neu= neu + ';';
		    	char *neu_w = &amp;neu.at(0);
			off&lt;&lt;neu_w;
    			off.close();
  		}else{
			is.close();
			off.open(next_w,ios::out|ios::app);
			off&lt;&lt;&quot;&quot;;
			off.close();
		}
	}

	void clearlist(char *begin_c,char *name){
		int i=0;
		int anz=0;
		string end_c =&quot;.c&quot;;
		string all_c = begin_c + end_c;
		char *next_c = &amp;all_c.at(0);
		is.open(next_c,ios::in);
		if(is.is_open()){
			is.seekg (0, ios::end);
  			int length_c = 0;
			length_c = is.tellg();
			char vor[length_c];
  			is.seekg (0, ios::beg);
			//Abfangschleife:Datei ist leer
			if(length_c==0)
			{
				is.close();
			}else{
				char *buffer_c = new char[length_c];
				is.read (buffer_c,length_c);
				memcpy(vor,buffer_c,length_c);
				for(int k= 0;k&lt;length_c;k++)
				{
					if(vor[k]==';')
					{
						anz++;
					}
				}
				string foo_c[anz];
				for(int h= 0;h&lt;length_c-1;h++)
				{
					if(vor[h]==';')
					{
						i++;
					}else{
						foo_c[i] +=vor[h];
					}

			 	}
				bool kontr= false;
				for(int j=0;j&lt;i;j++)
				{
				  	if(foo_c[j]== name)
					{
						for (int l=j; l&lt;i;l++)
				    		{
							foo_c[l]=foo_c[l+1];
						}
					kontr=true;	
					}
				}
				//Kontrallschleife: eigegebener Benutzer existiert nicht in der Kontaktliste
				if(kontr== false)
				{
					is.close();
				}else{
				 	is.close();
				 	off.open(next_c,ios::out);
				 	for(int l= 0;l&lt;i-1;l++)
					{
				 		off&lt;&lt;foo_c[l];
						off&lt;&lt;';';
				 	}
				 	off.close();
				}
			}
		}else{
			//Datei existiert nicht und wirde deshalb erzeugt
			is.close();
			off.open(next_c,ios::out|ios::app);
			off&lt;&lt;&quot;&quot;;
			off.close();		
		}
	}

};
 int main(){
    kontaktlist test(&quot;cat&quot;,&quot;hallo&quot;);
    return 0;
 }
</code></pre>
<p>versucht in eine Libary umzuwandeln:<br />
siehst du hier:<br />
<a href="http://www.rafb.net/paste/results/5lT5mF57.html" rel="nofollow">http://www.rafb.net/paste/results/5lT5mF57.html</a><br />
hab ich das so richtig gemacht?? (ist mein first try)<br />
bitte um Antworten.Thx.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/137173/schnelle-hilfe-bei-bibliothek-benötigt</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 16:53:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/137173.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Feb 2006 17:28:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to schnelle Hilfe bei Bibliothek benötigt on Wed, 15 Feb 2006 17:28:09 GMT]]></title><description><![CDATA[<p>Ich habe folgendes Program:</p>
<pre><code class="language-cpp">#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string&gt;
#include&lt;iostream&gt;
 #include&lt;fstream&gt;
#include&lt;vector&gt;

using namespace std;

class kontaktlist
{
public:
ifstream is;
ofstream off;

	kontaktlist(char* begin,char *neu) {
 		readlist(begin);
   		writelist(begin,neu);
  		clearlist(begin,neu);
	}

	vector&lt;string&gt; readlist (char *begin){
	        vector&lt;string&gt;foo_r;
	        string end=&quot;.c&quot;;
	        string all = begin + end;
	  	char *next_r = &amp;all.at(0);
		is.open(next_r,ios::in);
		  if (is.is_open())
		  {
			is.seekg (0, ios::end);
  		  	int length_r = 0;
		  	length_r = is.tellg();
  		  	is.seekg (0, ios::beg);
		  	char *buffer_r = new char[length_r];
			is.read (buffer_r,length_r);
		  	is.close();
			foo_r.push_back(buffer_r);
			return (foo_r);
		  	}else{
			is.close();
			off.open(next_r,ios::out|ios::app);
			off&lt;&lt;&quot;&quot;;
			off.close();
			return (foo_r);
		}
	}

	void writelist (char *begin,string neu){
		string end=&quot;.c&quot;;
	        string all = begin + end;
	  	char *next_w = &amp;all.at(0);
	    	is.open(next_w,ios::in);
		if (is.is_open())
  		{
			is.close();
			off.open(next_w,ios::out|ios::app);
    			neu= neu + ';';
		    	char *neu_w = &amp;neu.at(0);
			off&lt;&lt;neu_w;
    			off.close();
  		}else{
			is.close();
			off.open(next_w,ios::out|ios::app);
			off&lt;&lt;&quot;&quot;;
			off.close();
		}
	}

	void clearlist(char *begin_c,char *name){
		int i=0;
		int anz=0;
		string end_c =&quot;.c&quot;;
		string all_c = begin_c + end_c;
		char *next_c = &amp;all_c.at(0);
		is.open(next_c,ios::in);
		if(is.is_open()){
			is.seekg (0, ios::end);
  			int length_c = 0;
			length_c = is.tellg();
			char vor[length_c];
  			is.seekg (0, ios::beg);
			//Abfangschleife:Datei ist leer
			if(length_c==0)
			{
				is.close();
			}else{
				char *buffer_c = new char[length_c];
				is.read (buffer_c,length_c);
				memcpy(vor,buffer_c,length_c);
				for(int k= 0;k&lt;length_c;k++)
				{
					if(vor[k]==';')
					{
						anz++;
					}
				}
				string foo_c[anz];
				for(int h= 0;h&lt;length_c-1;h++)
				{
					if(vor[h]==';')
					{
						i++;
					}else{
						foo_c[i] +=vor[h];
					}

			 	}
				bool kontr= false;
				for(int j=0;j&lt;i;j++)
				{
				  	if(foo_c[j]== name)
					{
						for (int l=j; l&lt;i;l++)
				    		{
							foo_c[l]=foo_c[l+1];
						}
					kontr=true;	
					}
				}
				//Kontrallschleife: eigegebener Benutzer existiert nicht in der Kontaktliste
				if(kontr== false)
				{
					is.close();
				}else{
				 	is.close();
				 	off.open(next_c,ios::out);
				 	for(int l= 0;l&lt;i-1;l++)
					{
				 		off&lt;&lt;foo_c[l];
						off&lt;&lt;';';
				 	}
				 	off.close();
				}
			}
		}else{
			//Datei existiert nicht und wirde deshalb erzeugt
			is.close();
			off.open(next_c,ios::out|ios::app);
			off&lt;&lt;&quot;&quot;;
			off.close();		
		}
	}

};
 int main(){
    kontaktlist test(&quot;cat&quot;,&quot;hallo&quot;);
    return 0;
 }
</code></pre>
<p>versucht in eine Libary umzuwandeln:<br />
siehst du hier:<br />
<a href="http://www.rafb.net/paste/results/5lT5mF57.html" rel="nofollow">http://www.rafb.net/paste/results/5lT5mF57.html</a><br />
hab ich das so richtig gemacht?? (ist mein first try)<br />
bitte um Antworten.Thx.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/995132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/995132</guid><dc:creator><![CDATA[Dante McRayne]]></dc:creator><pubDate>Wed, 15 Feb 2006 17:28:09 GMT</pubDate></item></channel></rss>