c primer plus 第五版书上源码(更新)

例2.1

Code   ViewPrint
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
  1. #include "stdafx.h"
  2. int _tmain(int argc, _TCHAR* argv[])
  3. {
  4.     int num;
  5.     num =1;
  6.     printf("I am a sipmle ");
  7.     printf("computer.\n");
  8.     printf("My favorite number is %d because it is first.\n",num);
  9.     getchar();
  10.     return 0;
  11. }

例2.2 fathm_ft.c

Code   ViewPrint
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
  1. #include "stdafx.h"
  2. int _tmain(int argc, _TCHAR* argv[])
  3. {
  4.     int feet,fathoms;
  5.     fathoms = 2;
  6.     feet = 6 * fathoms;
  7.     printf("There are %d feet in %d fathoms!\n",feet,fathoms);
  8.     printf("Yes,I said %d feet!\n",6 * fathoms);
  9.     getchar();
  10.     return 0;
  11. }

例2.3 two_func.cpp

Code   ViewPrint
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
  1. #include "stdafx.h"
  2. void butler(void);
  3. int _tmain(int argc, _TCHAR* argv[])
  4. {
  5.     printf("I will summon the butler function.\n");
  6.     butler();
  7.     printf("Yes.Bring me some tea and writeable CD-ROMS.\n");
  8.     getchar();
  9.     return 0;
  10. }
  11. void butler(void)
  12. {
  13.     printf("You rang.sir?\n");
  14. }