Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   [C]: [Warning] return type of 'main' is not `int' ... (https://www.delphipraxis.net/118857-%5Bc%5D-%5Bwarning%5D-return-type-main-not-%60int.html)

Spiderpig_GER_15 16. Aug 2008 15:10


[C]: [Warning] return type of 'main' is not `int' ...
 
Hi,

ich bin grade dabei in C reinzuschnüffeln, aber der compiler sagt immer:

[Warning] return type of 'main' is not `int' ...
Code:
#include <conio.h>
#include <stdio.h>

void addieren(int zahl1, int zahl2);

void main(void)
{

getch();
}

void addieren(int zahl1, int zahl2)
{
 zahl1=zahl11+zahl2;      
}
Der Code und der Sinn sei in Dahingestellt...

kann mir jemand sagen woran das liegt?

MfG

Spiderpig

Apollonius 16. Aug 2008 15:12

Re: [C]: [Warning] return type of 'main' is not `int' ...
 
Hm. Mir kommt bei der Fehlermeldung irgendwie in den Sinn, dass die Main-Funktion int als Rückgabetyp haben sollte. Das muss eine Eingebung sein...

Spiderpig_GER_15 16. Aug 2008 15:15

Re: [C]: [Warning] return type of 'main' is not `int' ...
 
mhh, ohhh, jaaaa, natürlich :hello: :party:

nee, ist schon klar das da irgendwie was mit integer zurück soll aber wie gesagt, ich bin grad mal 2 stunden C'ler und ich weiß nicht was ich jetzt machen soll...

Apollonius 16. Aug 2008 15:20

Re: [C]: [Warning] return type of 'main' is not `int' ...
 
Code:
int main(void)

Dezipaitor 16. Aug 2008 15:23

Re: [C]: [Warning] return type of 'main' is not `int' ...
 
Code:
int main()
{
  return 0;
}
Schau mal auf dieser Seite. Da wirste gut beraten mit Tutorials und es gibt auch ein Forum :
http://www.c-plusplus.de/

Weazy 16. Aug 2008 15:54

Re: [C]: [Warning] return type of 'main' is not `int' ...
 
eine C Main Methode sollte (glaube mich erinnern zu können) 0 zurück geben wenn alles korrekt abgelaufen ist...

Torpedo 16. Aug 2008 18:32

Re: [C]: [Warning] return type of 'main' is not `int' ...
 
Code:
int main() {
    return 0;
}

so sollte es aussehen.

Dezipaitor 16. Aug 2008 18:39

Re: [C]: [Warning] return type of 'main' is not `int' ...
 
Ooopss, da hab ich geschlafen :)
Aber das "{" ohne Umbruch neben der Funktion ist Java-Style.

Torpedo 16. Aug 2008 18:41

Re: [C]: [Warning] return type of 'main' is not `int' ...
 
Zitat:

Zitat von Dezipaitor
Aber das "{" ohne Umbruch neben der Funktion ist Java-Style.

Das kann man schreiben wie man will. Das ist genau so C-Style wie mit Umbruch. Ich finde es ohne übersichtlicher.

Spiderpig_GER_15 16. Aug 2008 18:55

Re: [C]: [Warning] return type of 'main' is not `int' ...
 
vielen Dank, scheint zu klappen, leider weiß ich nicht warum man statt void int schreiben muss...


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:23 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz