In C, the scope of a variable staticthrough a file. In the following code, the function returns a static variable.
static
int fun(){ static int i = 10; return i; } int main() { printf("%d\n", fun()); return 0; }
And printed output 10.
So, returns local static to C behavior undefined or well-defined?
It seems you missed all the logic for the instruction return.
return
In this snippet, you are actually returning the value (of the variable), so without storage the staticcode is fine.
, , . static, ( ) , . ,
malloc()
Source: https://habr.com/ru/post/1689243/More articles:Должны ли использоваться целые числа с подписью или без знака для размеров? - c++Android: replay audio in Push-Notification - androidEstimate Excel VBA Boolean Condition (Not Formula) - vbaWhy can the structure declared by let be changed? - structStatic data memory limit in a C ++ application - c ++VueJS и Firebase, история 404 ошибка при обновлении - http-status-code-404https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1689245/thissetstate-not-working-when-a-parents-state-has-to-be-updated-by-a-child&usg=ALkJrhjQiCBfpi8nL6mv-c_UNBaFX7PKoQWhy Powershell Format-List * Does Not List All Properties - powershellhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1689247/sbt-fails-to-start-due-to-orgwebjarsnpmgraceful-readlink100&usg=ALkJrhicwx0Wnkj-CsO3ZuIliWC58ei_wAPHP - Webhook installation receiver with signature verification - phpAll Articles