欢迎来到天天文库
浏览记录
ID:43484663
大小:736.32 KB
页数:70页
时间:2019-10-07
《C_Primer_Plus(第五版)全书源代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、//chapter01/*#includeintmain(void){intdogs;printf("Howmanydogsdoyouhave?");scanf("%d",&dogs);printf("Soyouhave%ddog(s)!",dogs);return0;}*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////chapter02
2、//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);return0;}*////////////////////////////////////////////////////////////////////*#include3、.h>intmain(void)//asimpleprogram{intnum;//defineavariablecallednumnum=1;//assignavaluetonumprintf("Iamasimple");//usetheprintf()functionprintf("computer.");printf("Myfavoritenumberis%dbecauseitisfirst.",num);return0;}*/////////////////////////////////////////////////////////////////////two4、_func.c--aprogramusingtwofunctionsinonefile/*#includevoidbutler(void);//ISO/ANSICfunctionprototypingintmain(void){printf("Iwillsummonthebutlerfunction.");butler();printf("Yes.BringmesometeaandwriteableCD-ROMS.");return0;}voidbutler(void)//startoffunctiondefinition{printf("Yourang,5、sir?");}*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////chapter03数据和C/*//altnames.c--portablenamesforintegertypes#include#include//supportsportabletypesthesystemdoesn'tcontaintheheade6、rfileintmain(void){int16_tme16;//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;}*////////////////////////////7、////////////////////////////////////////*//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
3、.h>intmain(void)//asimpleprogram{intnum;//defineavariablecallednumnum=1;//assignavaluetonumprintf("Iamasimple");//usetheprintf()functionprintf("computer.");printf("Myfavoritenumberis%dbecauseitisfirst.",num);return0;}*/////////////////////////////////////////////////////////////////////two
4、_func.c--aprogramusingtwofunctionsinonefile/*#includevoidbutler(void);//ISO/ANSICfunctionprototypingintmain(void){printf("Iwillsummonthebutlerfunction.");butler();printf("Yes.BringmesometeaandwriteableCD-ROMS.");return0;}voidbutler(void)//startoffunctiondefinition{printf("Yourang,
5、sir?");}*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////chapter03数据和C/*//altnames.c--portablenamesforintegertypes#include#include//supportsportabletypesthesystemdoesn'tcontaintheheade
6、rfileintmain(void){int16_tme16;//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;}*////////////////////////////
7、////////////////////////////////////////*//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
此文档下载收益归作者所有