<?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[MemTotal anzeigen]]></title><description><![CDATA[<p>Hallo,<br />
Ich versuche ganz verzweifelt unter Linux<br />
einen Programm zu schreiben was dir anzeigt wv<br />
Arbeitspeicher dein Rechner hat .</p>
<pre><code class="language-cpp">fstream fout;
char buffer[1024];
 char* match;
 fout.open(&quot;/proc/meminfo&quot;,ios::out | ios::in);
 while(fout.good())
 {
      fout&gt;&gt;buffer;
 }
 match = strstr(buffer,&quot;MemTotal&quot;);
 if(match==NULL) exit(1);
 wxString mystring(match, wxConvUTF8);
   textctrl2-&gt;SetValue(mystring);
</code></pre>
<p>Irgendwie schliesst das Programm wenn ich auf button klick ...<br />
Das gleiche Programm hab ich mit C geschafft mit Filedeskriptor.</p>
<p>Grüsse</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/298179/memtotal-anzeigen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 23:33:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/298179.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 15 Jan 2012 10:03:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 10:03:18 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Ich versuche ganz verzweifelt unter Linux<br />
einen Programm zu schreiben was dir anzeigt wv<br />
Arbeitspeicher dein Rechner hat .</p>
<pre><code class="language-cpp">fstream fout;
char buffer[1024];
 char* match;
 fout.open(&quot;/proc/meminfo&quot;,ios::out | ios::in);
 while(fout.good())
 {
      fout&gt;&gt;buffer;
 }
 match = strstr(buffer,&quot;MemTotal&quot;);
 if(match==NULL) exit(1);
 wxString mystring(match, wxConvUTF8);
   textctrl2-&gt;SetValue(mystring);
</code></pre>
<p>Irgendwie schliesst das Programm wenn ich auf button klick ...<br />
Das gleiche Programm hab ich mit C geschafft mit Filedeskriptor.</p>
<p>Grüsse</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168248</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168248</guid><dc:creator><![CDATA[Cho++]]></dc:creator><pubDate>Sun, 15 Jan 2012 10:03:18 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 10:14:13 GMT]]></title><description><![CDATA[<p>Was genau denkst du macht Zeile 7?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168252</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168252</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Sun, 15 Jan 2012 10:14:13 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 10:15:20 GMT]]></title><description><![CDATA[<p>Die Datei sieht so oder so ähnlich aus:</p>
<pre><code>MemTotal:       16151304 kB
MemFree:         4449084 kB
Buffers:               8 kB
Cached:          8077000 kB
SwapCached:            0 kB
Active:          6641884 kB
Inactive:        2220244 kB
Active(anon):     797468 kB
Inactive(anon):   173136 kB
Active(file):    5844416 kB
Inactive(file):  2047108 kB
Unevictable:           8 kB
Mlocked:               8 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:              2652 kB
Writeback:             0 kB
AnonPages:        785484 kB
Mapped:          2358368 kB
Shmem:            185484 kB
Slab:             491160 kB
SReclaimable:     429792 kB
SUnreclaim:        61368 kB
KernelStack:        3304 kB
PageTables:        19676 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8075652 kB
Committed_AS:    6193684 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      321872 kB
VmallocChunk:   34359315727 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:        8192 kB
DirectMap2M:    16488448 kB
</code></pre>
<p>Wieso willste diese Datei zum Schreiben öffnen?<br />
Also damit kriege ich eine Zahl, auch wenn der Code nur mal kurz hingeschmiert ist, das wirste besser machen können:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;

using namespace std;

int main()
{
    ifstream in(&quot;/proc/meminfo&quot;);
    string name;
    int value;
    while(in&gt;&gt;name&gt;&gt;value &amp;&amp; in.ignore(1000,'\n')){
        if(name==&quot;MemTotal:&quot;)
            cout&lt;&lt;name&lt;&lt;value&lt;&lt;'\n';
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2168254</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168254</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sun, 15 Jan 2012 10:15:20 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 10:16:04 GMT]]></title><description><![CDATA[<p>Hmm ich hab fstream schon lange nicht verwendet aber ich glaub<br />
damit konnte man doch des was in der Datei meminfo ist raus lesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168255</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168255</guid><dc:creator><![CDATA[Cho++]]></dc:creator><pubDate>Sun, 15 Jan 2012 10:16:04 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 10:21:33 GMT]]></title><description><![CDATA[<p>AirTrake schrieb:</p>
<blockquote>
<p>Hmm ich hab fstream schon lange nicht verwendet aber ich glaub<br />
damit konnte man doch des was in der Datei meminfo ist raus lesen.</p>
</blockquote>
<p>Nein, wirklich!</p>
<p>Edit: Wenn du Windows hättest: GetPhysicallyInstalledSystemMemory()</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168256</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168256</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 15 Jan 2012 10:21:33 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 11:14:34 GMT]]></title><description><![CDATA[<p>Oder auf Linux:</p>
<pre><code class="language-cpp">#include &lt;sys/sysinfo.h&gt;
#include &lt;iostream&gt;
#include &lt;complex&gt;
#include &lt;iomanip&gt;

unsigned getAmountOfRAM()
{
    struct sysinfo i;

    if(!sysinfo(&amp;i))  
        return i.totalram;

    return 0;
}

int main()
{
    std::cout &lt;&lt; &quot;Amount of System Memory: &quot; &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; static_cast&lt;float&gt;(getAmountOfRAM()) / 1024 
    &lt;&lt; &quot; Megabytes\n&quot;;    
}
</code></pre>
<p><a href="http://ideone.com/41Ts3" rel="nofollow"><strong>Getestet</strong></a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168259</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168259</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 15 Jan 2012 11:14:34 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 10:28:37 GMT]]></title><description><![CDATA[<p>Ich bin gerade am lernen wie man mit dem System umgeht usw. deswegen waers mir<br />
lieber ohne funktionen . Ich weis aber nicht was ich falsch mach.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168261</guid><dc:creator><![CDATA[Cho++]]></dc:creator><pubDate>Sun, 15 Jan 2012 10:28:37 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 10:33:26 GMT]]></title><description><![CDATA[<p>@Hacker: Gib doch einfach -1 zurück, oder wirf einen runtime_error. Aber sicher keinen logic_error.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168262</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168262</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Sun, 15 Jan 2012 10:33:26 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 11:02:15 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>@Hacker: Gib doch einfach -1 zurück, oder wirf einen runtime_error. Aber sicher keinen logic_error.</p>
</blockquote>
<p>Editiert. Ich war in Eile (ohne Scheiß) <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="😉"
    /><br />
Und, falls es dir noch nicht aufgefallen ist, der Rückgabetyp ist unsigned. Da geb ich lieber einfach 0 zurück.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168271</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168271</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 15 Jan 2012 11:02:15 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 13:04:55 GMT]]></title><description><![CDATA[<p>Ja und wie kann ich des jetzt mit fstream machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168333</guid><dc:creator><![CDATA[Cho++]]></dc:creator><pubDate>Sun, 15 Jan 2012 13:04:55 GMT</pubDate></item><item><title><![CDATA[Reply to MemTotal anzeigen on Sun, 15 Jan 2012 13:53:32 GMT]]></title><description><![CDATA[<p>Upss Volkard hab dein beitrag nicht gesehen Super 1 Klappt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Vielen Dank an alle!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2168350</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2168350</guid><dc:creator><![CDATA[Cho++]]></dc:creator><pubDate>Sun, 15 Jan 2012 13:53:32 GMT</pubDate></item></channel></rss>