<?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[Uhr]]></title><description><![CDATA[<p>Wie bekomme ich eine Uhr hin?<br />
Z.B. in der Konsole soll oben rechts in der Ecke eine 1 stehen und dann jede Sekunde ein hochzählen. Also wie stelle ich fest das eine Sekunde vergangen ist? (Oder eine Millisekunde). Ich habe schon gegoogelt und auch vieles gefunden, aber ich kann mit den meisten Sachen (Beiträgen) nichts anfangen. Ich hoffe Ihr könnt mir das ein wenig erklären und eine einface aber auch gute Lösung vorschlagen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/325934/uhr</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 16:18:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/325934.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 24 May 2014 10:00:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Uhr on Sat, 24 May 2014 10:00:38 GMT]]></title><description><![CDATA[<p>Wie bekomme ich eine Uhr hin?<br />
Z.B. in der Konsole soll oben rechts in der Ecke eine 1 stehen und dann jede Sekunde ein hochzählen. Also wie stelle ich fest das eine Sekunde vergangen ist? (Oder eine Millisekunde). Ich habe schon gegoogelt und auch vieles gefunden, aber ich kann mit den meisten Sachen (Beiträgen) nichts anfangen. Ich hoffe Ihr könnt mir das ein wenig erklären und eine einface aber auch gute Lösung vorschlagen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400628</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400628</guid><dc:creator><![CDATA[keinerahnung]]></dc:creator><pubDate>Sat, 24 May 2014 10:00:38 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr on Sat, 24 May 2014 10:21:02 GMT]]></title><description><![CDATA[<blockquote>
<p>Z.B. in der Konsole soll oben rechts in der Ecke eine 1 stehen</p>
</blockquote>
<p>C++ kennt keine Konsolen. Wenn du Konsolen-Graphik machen willst, musst du Plattformabhängige APIs (wie die allbekannte WinAPI) verwenden.</p>
<p>Ein einfaches Beispiel, wie mann die Zeit in einen String packt und diesen ausgibt:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;ctime&gt;

int main()
{
	auto t = std::time(nullptr);
	std::string str(100, '\0');
	std::strftime( &amp;str[0], str.size(), &quot;%H:%M:%S&quot;, std::localtime(&amp;t) );
	std::cout &lt;&lt; str &lt;&lt; '\n';
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2400629</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400629</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 24 May 2014 10:21:02 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr on Sat, 24 May 2014 10:46:50 GMT]]></title><description><![CDATA[<p>Danke für die Antwort. Aber könntest du mir die Zeilen etwas erklären?</p>
<pre><code>auto t = std::time(nullptr);
    std::string str(100, '\0');
    std::strftime( &amp;str[0], str.size(), &quot;%H:%M:%S&quot;, std::localtime(&amp;t) );
</code></pre>
<p>Oder mir einen Link geben wo ich genau das nachlesen kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400630</guid><dc:creator><![CDATA[keinerahn]]></dc:creator><pubDate>Sat, 24 May 2014 10:46:50 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr on Sat, 24 May 2014 10:56:21 GMT]]></title><description><![CDATA[<p><a href="http://en.cppreference.com/w/cpp/chrono/c/strftime" rel="nofollow"> <code>std::strftime</code> </a>,<a href="http://en.cppreference.com/w/cpp/chrono/c/time" rel="nofollow"> <code>std::time</code> </a>,<a href="http://en.cppreference.com/w/cpp/chrono/c/tm" rel="nofollow"> <code>std::tm</code> </a>.</p>
<p>Und natürlich: <a href="http://bit.ly/RlOUok" rel="nofollow">http://bit.ly/RlOUok</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400632</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400632</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 24 May 2014 10:56:21 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr on Sat, 24 May 2014 15:55:52 GMT]]></title><description><![CDATA[<p>Edit: Alles gelöscht war mist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400658</guid><dc:creator><![CDATA[Skeptar]]></dc:creator><pubDate>Sat, 24 May 2014 15:55:52 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr on Sat, 24 May 2014 15:56:29 GMT]]></title><description><![CDATA[<p>Arcoth schrieb:</p>
<blockquote>
<p><a href="http://en.cppreference.com/w/cpp/chrono/c/strftime" rel="nofollow"> <code>std::strftime</code> </a>,<a href="http://en.cppreference.com/w/cpp/chrono/c/time" rel="nofollow"> <code>std::time</code> </a>,<a href="http://en.cppreference.com/w/cpp/chrono/c/tm" rel="nofollow"> <code>std::tm</code> </a>.</p>
<p>Und natürlich: <a href="http://bit.ly/RlOUok" rel="nofollow">http://bit.ly/RlOUok</a></p>
</blockquote>
<p>danke danke!<br />
Aber ich vestehe es nicht (war zu erwarten...)<br />
Ich habe das hier</p>
<pre><code>std::strftime( &amp;str[0], str.size(), &quot;%H:%M:%S&quot;, std::localtime(&amp;t) );
</code></pre>
<p>So verstanden das daraus eine &quot;Uhrzeit&quot; gemacht wird. Und bei dem Rest so gar nichts <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Es wäre nett wenn du mir ein paar deutsche Worte dazu sagen könntest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400659</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400659</guid><dc:creator><![CDATA[keinerahnung]]></dc:creator><pubDate>Sat, 24 May 2014 15:56:29 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr on Sat, 24 May 2014 16:18:40 GMT]]></title><description><![CDATA[<pre><code>auto t = std::time(nullptr);
    // t wird initialisiert mit der Anzahl der Sekunden seit dem Epoch.
std::string str(100, '\0');
    // Initialisiert einen leeren String mit hundert Zeichen.
std::strftime( &amp;str[0], str.size(), &quot;%H:%M:%S&quot;, std::localtime(&amp;t) );
    /* localtime macht aus der Anzahl der Sekunden eine Datenstruktur, die Monate, Tage, Jahre, Minuten usw. enthält. 
       Diese werden dann anschließend mittels strftime formatiert in den String geschrieben. */
</code></pre>
<p>Zusätzlich kann das ganze noch folgendermaßen verbessert werden: Die Anfangsgröße des Strings kann locker auf zehn reduziert werden, und folgende Zeilen können auch nicht schaden:</p>
<pre><code>auto size = std::strftime( &amp;str[0], str.size(), &quot;%H:%M:%S&quot;, std::localtime(&amp;t) );
str.resize( size );
// str.shrink_to_fit();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2400663</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400663</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 24 May 2014 16:18:40 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr on Sat, 24 May 2014 19:58:14 GMT]]></title><description><![CDATA[<p>Okay danke!<br />
Jedzt habe ich noch eine Frage (die hat nur noch teilweise etwas mit der zu tun)<br />
Wie bekomme ich es hin das 2 &quot;Prozesse&quot; gleichzeitig laufen?<br />
Sprich, es soll ein Name eingeben werden und nebenbei soll eine Uhrzeit laufen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400710</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400710</guid><dc:creator><![CDATA[keinerahnung]]></dc:creator><pubDate>Sat, 24 May 2014 19:58:14 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr on Sat, 24 May 2014 20:25:48 GMT]]></title><description><![CDATA[<p>Ich glaube, was du suchst ist ein GUI-Toolkit. Denn so etwas kann man auf der Konsole mit Standard-C++ definitiv <strong>nicht</strong> machen (und damit wäre der Fall für dieses Board erledigt), und ob das mit der WinAPI geht weiß ich nicht - ggf. mach aber dort einen Thread auf.</p>
<blockquote>
<p>Wie bekomme ich es hin das 2 &quot;Prozesse&quot; gleichzeitig laufen?</p>
</blockquote>
<p>Du meinst wohl Threads.<br />
Seit C++11 gibt es die Klasse<a href="http://en.cppreference.com/w/cpp/thread/thread" rel="nofollow"> <code>std::thread</code> </a>, welche einen separaten Thread repräsentiert. Es gibt auch <code>std::async</code> . Falls du dir jetzt aber Multithreading in C++11 aneignen willst, such dir ein Buch oder Google das mal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2400718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2400718</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 24 May 2014 20:25:48 GMT</pubDate></item></channel></rss>