<?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[convert timeval to int]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte der Zeitstempel ausgeben. Kann aber keine gettimeofday(&amp;time, NULL); benutzen, weil meine Entsicklungumgebung es nicht unterstützt.</p>
<p>Meine Codeausschnitt:</p>
<pre><code>time_t t;
		struct timeval tv;
		t = time(0);
		tv =  (long int)((int)localtime(((const time_t*)(&amp; t))));
</code></pre>
<p>Problematisch ist die Zeile tv = (long int)((int)localtime(((const time_t*)(&amp; t)))); error: no match for 'operator=' in 'tv = (long int)((int)localtime(((const time_t*)(&amp; t))))'</p>
<p>kennt jemand due Lösung?<br />
vielen Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/310258/convert-timeval-to-int</link><generator>RSS for Node</generator><lastBuildDate>Tue, 04 Aug 2026 21:06:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/310258.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Nov 2012 13:22:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to convert timeval to int on Wed, 07 Nov 2012 13:22:40 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte der Zeitstempel ausgeben. Kann aber keine gettimeofday(&amp;time, NULL); benutzen, weil meine Entsicklungumgebung es nicht unterstützt.</p>
<p>Meine Codeausschnitt:</p>
<pre><code>time_t t;
		struct timeval tv;
		t = time(0);
		tv =  (long int)((int)localtime(((const time_t*)(&amp; t))));
</code></pre>
<p>Problematisch ist die Zeile tv = (long int)((int)localtime(((const time_t*)(&amp; t)))); error: no match for 'operator=' in 'tv = (long int)((int)localtime(((const time_t*)(&amp; t))))'</p>
<p>kennt jemand due Lösung?<br />
vielen Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2268546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2268546</guid><dc:creator><![CDATA[bijiko]]></dc:creator><pubDate>Wed, 07 Nov 2012 13:22:40 GMT</pubDate></item><item><title><![CDATA[Reply to convert timeval to int on Wed, 07 Nov 2012 16:46:01 GMT]]></title><description><![CDATA[<p>Du willst einen Zeitstempel ausgeben?</p>
<p>Mach es in C++98/03 einfach so:</p>
<pre><code>std::time_t sec = std::time(NULL);
std::cout &lt;&lt; std::asctime(std::localtime(&amp;sec));
</code></pre>
<p><strong>Ideone</strong>: <a href="http://ideone.com/YoxczF" rel="nofollow">http://ideone.com/YoxczF</a></p>
<p>Seit C++11 geht das mit<a href="http://de.cppreference.com/w/cpp/chrono/c/ctime" rel="nofollow"> <code>std::ctime</code> </a>aus Chrono einfacher.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2268561</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2268561</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 07 Nov 2012 16:46:01 GMT</pubDate></item><item><title><![CDATA[Reply to convert timeval to int on Wed, 07 Nov 2012 16:34:01 GMT]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;
#include &lt;ctime&gt;
int main()
{
    std::cout &lt;&lt; std::time(0);
}
</code></pre>
<p>?</p>
<p>Es ist zwar streng genommen nicht garantiert, aber du darfst davon ausgehen, dass time_t ein arithmetischer, ja sogar ein Ganzzahltyp ist. Und die kann man direkt ausgeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2268620</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2268620</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 07 Nov 2012 16:34:01 GMT</pubDate></item><item><title><![CDATA[Reply to convert timeval to int on Wed, 07 Nov 2012 16:44:44 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<pre><code>#include &lt;iostream&gt;
#include &lt;ctime&gt;
int main()
{
    std::cout &lt;&lt; std::time(0);
}
</code></pre>
<p>?</p>
<p>Es ist zwar streng genommen nicht garantiert, aber du darfst davon ausgehen, dass time_t ein arithmetischer, ja sogar ein Ganzzahltyp ist. Und die kann man direkt ausgeben.</p>
</blockquote>
<p>Ähm, er will doch einen Zeitstempel, nicht die Anzahl der Sekunden seit dem 1.1.1970?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2268624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2268624</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 07 Nov 2012 16:44:44 GMT</pubDate></item><item><title><![CDATA[Reply to convert timeval to int on Wed, 07 Nov 2012 16:55:42 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>Ähm, er will doch einen Zeitstempel, nicht die Anzahl der Sekunden seit dem 1.1.1970?</p>
</blockquote>
<p>Eine eineindeutige Zuordnung zwischen einer Zeichenfolge und einer Zeit. Klingt für mich schon irgendwie nach einem Zeitstempel. Und erfüllt trivial die geforderte Randbedingung, einen Ganzzahltypen zu benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2268626</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2268626</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 07 Nov 2012 16:55:42 GMT</pubDate></item><item><title><![CDATA[Reply to convert timeval to int on Wed, 07 Nov 2012 16:59:57 GMT]]></title><description><![CDATA[<p>Btw, zum Anfangsproblem:</p>
<blockquote>
<p>tv = (long int)((int)localtime(((const time_t*)(&amp; t)))); error: no match for 'operator=' in 'tv = (long int)((int)localtime(((const time_t*)(&amp; t))))'</p>
</blockquote>
<pre><code>(long int)((int)localtime(((const time_t*)(&amp; t))));
//&lt;=&gt; 
(long int)localtime(&amp;t);
</code></pre>
<p>Man sieht sofort: Zuerst castest du einen Zeiger in eine Ganzzahl, dann weist du diese Ganzzahl wieder einem Zeiger zu... und letzteres ist (Ausnahme: 0, bzw. NULL) verboten.</p>
<p>Wenn du die Anzahl der vergangenen Sekunden seit dem 1.1.1970 in einem timeval-Objekt speichern möchtest, dann geht das so:</p>
<pre><code>timeval tv;// elaborated type specifiers kannst du bei Deklarationen in C++ weglassen
tv.tv_sec =  time(NULL);
</code></pre>
<p>Allerdings bin ich mittlerweile irritiert was er überhaupt will <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2268630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2268630</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 07 Nov 2012 16:59:57 GMT</pubDate></item><item><title><![CDATA[Reply to convert timeval to int on Wed, 07 Nov 2012 17:04:13 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<p>Ähm, er will doch einen Zeitstempel, nicht die Anzahl der Sekunden seit dem 1.1.1970?</p>
</blockquote>
<p>Eine eineindeutige Zuordnung zwischen einer Zeichenfolge und einer Zeit. Klingt für mich schon irgendwie nach einem Zeitstempel. Und erfüllt trivial die geforderte Randbedingung, einen Ganzzahltypen zu benutzen.</p>
</blockquote>
<p>geforderte Randbedingung? Wo denn das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2268632</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2268632</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 07 Nov 2012 17:04:13 GMT</pubDate></item><item><title><![CDATA[Reply to convert timeval to int on Wed, 07 Nov 2012 17:04:21 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>danke für die ihre Hilfe. Ich brauche wirklich einen zeistempel. Dabei ist am wichtigste in diesem Fall aktuelle Millisekunden. Da meine Entwicklunsumgebung sehr empfindlich ist, kann ich</p>
<pre><code>structur timeval tv [code] benutzen und microsekunden
</code></pre>
<p>tv-&gt;tv_usec;[code=&quot;cpp&quot;] berechnen, klappt aber mit der Konvertierung (long int) to (int) nicht.</p>
<p>Die Windows Funktionen kann ich auch nicht Benutzen.</p>
<p>Grüße, Nino</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2268633</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2268633</guid><dc:creator><![CDATA[babadulia]]></dc:creator><pubDate>Wed, 07 Nov 2012 17:04:21 GMT</pubDate></item><item><title><![CDATA[Reply to convert timeval to int on Wed, 07 Nov 2012 17:08:41 GMT]]></title><description><![CDATA[<p>Mit C++98/03 gibt es keine Standardwege, die aktuelle Zeit millisekundengenau zu berechnen. In einem anderen Thread habe ich gezeigt wie es geht, wenn dein Compiler aktuell genug ist (bzw. du Boost hast, aber dann geht es auch mit Boost.Date_Time und einfacher).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2268634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2268634</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 07 Nov 2012 17:08:41 GMT</pubDate></item></channel></rss>