资源描述:
《C_Primer_Plus(第五版)全书源代码.pdf》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、//chapter01/*#includeintmain(void){intdogs;printf("Howmanydogsdoyouhave?");scanf("%d",&dogs);printf("Soyouhave%ddog(s)!",dogs);return0;}*////////////////////////////////////////////////////////////////////////////////////////////////////
2、///////////////////////////////////chapter02//fathm_ft.c--converts2fathomstofeet/*#includeintmain(void){intfeet,fathoms;fathoms=2;feet=6*fathoms;printf("Thereare%dfeetin%dfathoms!",feet,fathoms);printf("Yes,Isaid%dfeet!",6*fathoms);retur
3、n0;}*////////////////////////////////////////////////////////////////////*#includeintmain(void)//asimpleprogram{intnum;//defineavariablecallednumnum=1;//assignavaluetonumprintf("Iamasimple");//usetheprintf()functionprintf("computer.");prin
4、tf("Myfavoritenumberis%dbecauseitisfirst.",num);return0;}*/////////////////////////////////////////////////////////////////////two_func.c--aprogramusingtwofunctionsinonefile/*#includevoidbutler(void);//ISO/ANSICfunctionprototypingintmain(v
5、oid){printf("Iwillsummonthebutlerfunction.");butler();printf("Yes.BringmesometeaandwriteableCD-ROMS.");return0;}voidbutler(void)//startoffunctiondefinition{printf("Yourang,sir?");}*///////////////////////////////////////////////////////////////
6、////////////////////////////////////////////////////////////////////////chapter03数据和C/*//altnames.c--portablenamesforintegertypes#include#include//supportsportabletypesthesystemdoesn'tcontaintheheaderfileintmain(void){int16_tme16
7、;//me16a16-bitsignedvariableme16=4593;printf("First,assumeint16_tisshort:");printf("me16=%hd",me16);printf("Next,let'snotmakeanyassumptions.");printf("Instead,usea"macro"frominttypes.h:");printf("me16=%"PRId16"",me16);return0;}*//////////////
8、//////////////////////////////////////////////////////*//bases.c--prints100indecimal,octal,andhex#includeintmain(void){intx=100;printf("dec=%d;octal=%o;hex=%x",x,x,x);printf("dec=%d;octal=%#o;hex=%#x",x,x,x);//%#十六进制前显示Ox//八进制数前显示oreturn