Writing Portable Programs

  1. Size of Data Types
    1. Always use sizeof() to get the size of types(sizeof(char), sizeof(short), sizeof(int)...)
  2. Do not depend on the order of evaluation in an expression
  3. Char type may be singed or unsigned. Better to use an integer to store the output of getchar().
  4. Use standard Libraries
  5. Write platform-specific code is possible.

Reference from http://www.cs.princeton.edu/courses/archive/spring06/cos217/lectures/24portable.pdfspring

相關文章
相關標籤/搜索