<?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[Sich wiederholendes Programm ohne Endlosschleife?]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich hab ein kleines Programm geschrieben, welches überprüft ob eine Datei vorhanden ist und in Abhängigkeit davon eine andere umbenennt.<br />
Diese Kontrolle soll alle 5 Sekunden stattfinden.</p>
<p>Funktioniert auch, jedoch ist mein Prozessor zu 97% ausgelastet oO<br />
Wohl da es eine Endlosschleife ist. Das ganze ist eine Konsolenanwendung.</p>
<p>Hat jemand ne Idee wie ich das ganze anders lösen könnte?</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;windows.h&gt;<br />
#include &lt;time.h&gt;</p>
<p>using namespace std;</p>
<p>int main(){<br />
/*<br />
//Verstecken der Konsole<br />
HWND hwnd = FindWindow(&quot;ConsoleWindowClass&quot;,NULL);<br />
ShowWindow(hwnd,SW_HIDE);<br />
//cout &lt;&lt; &quot;Oo\n&quot;;<br />
*/</p>
<p>int i = 0;<br />
int temp = 0;</p>
<p>while(i&lt; 2) {<br />
temp = clock() + 5000;</p>
<p>while (clock() &lt; temp) {}<br />
//hier wird geprüft ob .pdf vorhanden ist</p>
<p>ifstream fin(&quot;C:\\fax.pdf&quot;);<br />
if (fin)<br />
{<br />
//cout &lt;&lt; &quot;File found&quot; &lt;&lt; endl;<br />
fin.close();</p>
<p>//hier wird geprüft ob .txt vorhanden ist<br />
ifstream fin(&quot;C:\\fax.txt&quot;);<br />
if (fin)<br />
{<br />
//cout &lt;&lt; &quot;File found&quot; &lt;&lt; endl;</p>
<p>//sind .pdf UND .txt vorhanden, dann wird .txt in .fax umbenannt.<br />
fin.close();<br />
rename(&quot;C:\\fax.txt&quot;, &quot;C:\\fax.fax&quot;);<br />
}</p>
<p>}</p>
<p>else<br />
{<br />
//cout &lt;&lt; &quot;Could not find file!&quot; &lt;&lt; endl;<br />
}</p>
<p>}<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/273770/sich-wiederholendes-programm-ohne-endlosschleife</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 23:31:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/273770.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Sep 2010 07:29:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sich wiederholendes Programm ohne Endlosschleife? on Mon, 13 Sep 2010 07:29:00 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich hab ein kleines Programm geschrieben, welches überprüft ob eine Datei vorhanden ist und in Abhängigkeit davon eine andere umbenennt.<br />
Diese Kontrolle soll alle 5 Sekunden stattfinden.</p>
<p>Funktioniert auch, jedoch ist mein Prozessor zu 97% ausgelastet oO<br />
Wohl da es eine Endlosschleife ist. Das ganze ist eine Konsolenanwendung.</p>
<p>Hat jemand ne Idee wie ich das ganze anders lösen könnte?</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;windows.h&gt;<br />
#include &lt;time.h&gt;</p>
<p>using namespace std;</p>
<p>int main(){<br />
/*<br />
//Verstecken der Konsole<br />
HWND hwnd = FindWindow(&quot;ConsoleWindowClass&quot;,NULL);<br />
ShowWindow(hwnd,SW_HIDE);<br />
//cout &lt;&lt; &quot;Oo\n&quot;;<br />
*/</p>
<p>int i = 0;<br />
int temp = 0;</p>
<p>while(i&lt; 2) {<br />
temp = clock() + 5000;</p>
<p>while (clock() &lt; temp) {}<br />
//hier wird geprüft ob .pdf vorhanden ist</p>
<p>ifstream fin(&quot;C:\\fax.pdf&quot;);<br />
if (fin)<br />
{<br />
//cout &lt;&lt; &quot;File found&quot; &lt;&lt; endl;<br />
fin.close();</p>
<p>//hier wird geprüft ob .txt vorhanden ist<br />
ifstream fin(&quot;C:\\fax.txt&quot;);<br />
if (fin)<br />
{<br />
//cout &lt;&lt; &quot;File found&quot; &lt;&lt; endl;</p>
<p>//sind .pdf UND .txt vorhanden, dann wird .txt in .fax umbenannt.<br />
fin.close();<br />
rename(&quot;C:\\fax.txt&quot;, &quot;C:\\fax.fax&quot;);<br />
}</p>
<p>}</p>
<p>else<br />
{<br />
//cout &lt;&lt; &quot;Could not find file!&quot; &lt;&lt; endl;<br />
}</p>
<p>}<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951814</guid><dc:creator><![CDATA[JonnyDaVinci]]></dc:creator><pubDate>Mon, 13 Sep 2010 07:29:00 GMT</pubDate></item><item><title><![CDATA[Reply to Sich wiederholendes Programm ohne Endlosschleife? on Mon, 13 Sep 2010 07:31:55 GMT]]></title><description><![CDATA[<p>Da du sowieso windows.h benutzt, pack in deine Schleife einfach ein Sleep(100) 'rein, dann wird deine CPU auch nicht so heiß. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951819</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951819</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Mon, 13 Sep 2010 07:31:55 GMT</pubDate></item><item><title><![CDATA[Reply to Sich wiederholendes Programm ohne Endlosschleife? on Mon, 13 Sep 2010 07:36:19 GMT]]></title><description><![CDATA[<p>Du erzeugst 100% CPU Last dadurch, dass du ununterbrochen prüfst, ob bereits 5 Sekunden vergangen sind.<br />
Die Win32 API bietet die Funktion Sleep an, mit der sich Prozess für eine Anzahl von Millisekunden schlafen legt und die CPU an andere Prozesse abgibt. Wie die Funktion für andere Betriebssysteme heisst weiß ich nicht, sie existiert aber mit Sicherheit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951822</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Mon, 13 Sep 2010 07:36:19 GMT</pubDate></item><item><title><![CDATA[Reply to Sich wiederholendes Programm ohne Endlosschleife? on Mon, 13 Sep 2010 07:40:34 GMT]]></title><description><![CDATA[<p>Danke erst mal für die Antworten!</p>
<p>Obwohl ich die windos.h drinne habe aktzeptiert er sleep(); nicht....</p>
<p>...not declared in this scope..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951825</guid><dc:creator><![CDATA[JonnyDaVinci]]></dc:creator><pubDate>Mon, 13 Sep 2010 07:40:34 GMT</pubDate></item><item><title><![CDATA[Reply to Sich wiederholendes Programm ohne Endlosschleife? on Mon, 13 Sep 2010 07:49:47 GMT]]></title><description><![CDATA[<p>C/C++ sind case sensitive...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951827</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951827</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Mon, 13 Sep 2010 07:49:47 GMT</pubDate></item><item><title><![CDATA[Reply to Sich wiederholendes Programm ohne Endlosschleife? on Mon, 13 Sep 2010 08:42:46 GMT]]></title><description><![CDATA[<p>DANKE!</p>
<p>So einfach kanns manchmal sein!</p>
<p>Läuft.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951843</guid><dc:creator><![CDATA[JonnyDaVinci]]></dc:creator><pubDate>Mon, 13 Sep 2010 08:42:46 GMT</pubDate></item></channel></rss>