C/Program: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
Nie podano opisu zmian
Linia 130:
===Jaki jest minimalny program ? ===
[[C/Pierwszy program|Najmniejszy program]], który daje się skompilować i uruchomić:
<sourcesyntaxhighlight lang=c>
void main(){}
</syntaxhighlight>
</source>
 
Jeśli skompilujemy :
Linia 140:
to otrzymujemy ostrzeżenie ( nie błąd) :
 
<sourcesyntaxhighlight lang=bash>
m.c:1:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
void main(){}
</syntaxhighlight>
</source>
 
Rozwiązanie: zmienić typ wyniku funkcji main na int<ref>[https://stackoverflow.com/questions/204476/what-should-main-return-in-c-and-c stackoverflow question: what-should-main-return-in-c-and-c]</ref>
 
<sourcesyntaxhighlight lang=c>
int main(){
 
return 0;}
</syntaxhighlight>
</source>
 
Teraz program kompiluje i wykonuje się bez problemów