compiler errors - Problem compiling simple C++ progam -


I found this simple C ++ [I think] the program was provided to check the maximum size int Which can be archived:

  #include & lt; Limits.h & gt; # Include & lt; Iostream & gt; Zero main (int argc, char * argv []) {cout & lt; & Lt; "INT_MAX" & lt; & Lt; INT_MAX & lt; & Lt; Andal; Cout & lt; & Lt; "INT_MAX +1 =" & lt; & Lt; INT_MAX + 1 & lt; & Lt; Andal; Cout & lt; & Lt; "INT_MAX -1 =" & lt; & Lt; INT_MAX - 1 & lt; & Lt; Andal; Cout & lt; & Lt; "INT_MAX / INT_MAX" & lt; & Lt; INT_MAX / INT_MAX & lt; & Lt; Andal; Cout & lt; & Lt; "(INT_MAX +1) / INT_MAX" & lt; & Lt; (INT_MAX +1) / INT_MAX & lt; & Lt; Endl; Cout & lt; & Lt; "(INT_MAX -1) / INT_MAX" & lt; & Lt; (INT_MAX-1) / INT_MAX & lt; & Lt; Endl; Cout & lt; & Lt; "INT_MAX / (INT_MAX +1)" & lt; & Lt; INT_MAX / (INT_MAX + 1) & lt; & Lt; Endl; Cout & lt; & Lt; "INT_MAX / (INT_MAX -1)" & lt; & Lt; INT_MAX / (INT_MAX-1) & lt; & Lt; Endl; }  

I am trying to compile:

  gcc -o int_max int_max.cpp  

but I get the following error:

  int_max.cpp: 4: error: ':: main' should return 'int' int_max.cpp: 'int main (int, char * *) ': Int_max.cpp: 8: Error:' cout 'has not been declared in this area int_max.cpp: 8: Error:' endless' in this area has not been declared int_max.cpp: 9: Warning: Expression int_max Overlaw integer in .cpp: 13: Warning: expression in integer o Vertflow int_max.cpp: 15: Warning: Integer multiplication in expression  

I tried to add return 0 at the end of the main, but he did not help. Any ideas I have done wrong?

It's possible that this is actually a snippet, but I think the lecturer was saying C ++.

Cheers

file with .c In the GCC are compiling the C ++ code> Extensions?

  // Use the new C ++ header file instead of their .h version. #include & lt; Climits & gt; # Include & lt; Iostream & gt; // cout and endl are declared in std namespace. using namespace std; Int main (int argc, char * argv []) {cout & lt; & Lt; "INT_MAX" & lt; & Lt; INT_MAX & lt; & Lt; Andal; Cout & lt; & Lt; "INT_MAX +1 =" & lt; & Lt; INT_MAX + 1 & lt; & Lt; Andal; Cout & lt; & Lt; "INT_MAX -1 =" & lt; & Lt; INT_MAX - 1 & lt; & Lt; Andal; Cout & lt; & Lt; "INT_MAX / INT_MAX" & lt; & Lt; INT_MAX / INT_MAX & lt; & Lt; Andal; Cout & lt; & Lt; "(INT_MAX +1) / INT_MAX" & lt; & Lt; (INT_MAX +1) / INT_MAX & lt; & Lt; Endl; Cout & lt; & Lt; "(INT_MAX -1) / INT_MAX" & lt; & Lt; (INT_MAX-1) / INT_MAX & lt; & Lt; Endl; Cout & lt; & Lt; "INT_MAX / (INT_MAX +1)" & lt; & Lt; INT_MAX / (INT_MAX + 1) & lt; & Lt; Endl; Cout & lt; & Lt; "INT_MAX / (INT_MAX -1)" & lt; & Lt; INT_MAX / (INT_MAX-1) & lt; & Lt; Endl; Return 0; }  

and use g ++ to compile.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -