{"id":711,"date":"2015-10-27T11:16:07","date_gmt":"2015-10-27T11:16:07","guid":{"rendered":"http:\/\/coolt.ch\/notizen\/?p=711"},"modified":"2015-10-27T11:29:02","modified_gmt":"2015-10-27T11:29:02","slug":"keyword-static-in-c","status":"publish","type":"post","link":"https:\/\/coolt.ch\/notizen\/keyword-static-in-c\/","title":{"rendered":"Keyword static in C"},"content":{"rendered":"<p><a href=\"http:\/\/coolt.ch\/notizen\/statische-dynamische-variablen\/\"><em>static <\/em><strong>lokale Variable<\/strong><\/a><br \/>\n&#8211; Ziel:<br \/>\nDie Variable <strong>beh\u00e4lt ihren Wert zwischen zwei lokalen Funktionsaufrufen<\/strong>.<br \/>\nDie Initialisierung gilt nur beim ersten Mal (Ablegen auf dem Datensegment).<br \/>\n&#8211; Sichtbarkeit:<br \/>\nDer G\u00fcltigkeitsbereich bleibt gleich. Der Ablageort der Variable ist auf dem Datensegment anstelle des Stacks.<br \/>\n&#8211; Bsp: Z\u00e4hlen von Interrupts<\/p>\n<pre class=\"lang:sh decode:true\">&lt;type&gt; function( ){\r\n.       static int nr_of_calls = 0;\r\n.\r\n.       \/\/ do some code\r\n.\r\n       nr_of_calls ++;\r\n.      return &lt;type&gt;;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>static <strong>globale Variable<\/strong><strong><br \/>\n<\/strong>&#8211; Ziel:<strong><br \/>\n<\/strong>Wie bei der lokalen statischen Variable. Zwischen den Aufrufen beh\u00e4lt die Variable den Wert. Wenn sie global ist, dann beh\u00e4lt sie den Wert w\u00e4hrend der ganzen Programmdauer.<br \/>\n&#8211; Sichtbarkeit:<br \/>\nEine externe Variable mit static ist <strong>ausserhalb der Datei unsichtbar!<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>static <strong>Funktion<br \/>\n<\/strong>&#8211; Sichtbarkeit:<br \/>\nWird eine Funktion extern und static gesetzt, dann ist sie ausserhalb der Datei nicht sichtbar.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>static lokale Variable &#8211; Ziel: Die Variable beh\u00e4lt ihren Wert zwischen zwei lokalen Funktionsaufrufen. Die Initialisierung gilt nur beim ersten Mal (Ablegen auf dem Datensegment). &#8211; Sichtbarkeit: Der G\u00fcltigkeitsbereich bleibt gleich. Der Ablageort der Variable ist auf dem Datensegment anstelle des Stacks. &#8211; Bsp: Z\u00e4hlen von Interrupts &lt;type&gt; function( ){ . static int nr_of_calls = &hellip; <a href=\"https:\/\/coolt.ch\/notizen\/keyword-static-in-c\/\" class=\"more-link\"><span class=\"screen-reader-text\">Keyword static in C<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[29],"tags":[11],"_links":{"self":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/711"}],"collection":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/comments?post=711"}],"version-history":[{"count":4,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/711\/revisions"}],"predecessor-version":[{"id":754,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/711\/revisions\/754"}],"wp:attachment":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/media?parent=711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/categories?post=711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/tags?post=711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}