Portabilty - 2004 Rocky Mountain Regional ACM
Using the provided examples will save you time and portability
problems
Declare main like this:
int main(int argc, char *argv[])
You don't have to use the argc and argv arguments. But you should
return an integer instead of nothing:
return 0;
C++: explicitly state "using namespace std":
#include <string>
#include <iotream>
using namespace std;
Microsoft has non-portable rules about the scope of variables
declared at the beginning of a for loop:
for (int i=0; i<10; ++i) {
...
}
<-- i still lives here on a microsoft compiler (which is nonstandard)
To get a consistent scope for i,
{for (int i=0; i<10; ++i) {
...
}}
<-- i is out of scope on microsoft or gcc compiler
64 bit integers have two different declarations between microsoft
and gcc
You can portably do this:
#ifdef _MSC_VER
typedef __int64 int64_t;
#else
typedef long long int64_t;
#endif
After this "int64_t" will mean a 64-bit int on either the microsoft or
gcc compiler.