//
/*
#include
int dogs;
chapter 01
printf(\ scanf(\
printf(\
return 0; } */
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
//
chapter 02
// fathm_ft.c -- converts 2 fathoms to feet /*
#include
int feet, fathoms;
fathoms = 2; feet = 6 * fathoms;
printf(\ printf(\
return 0; } */
////////////////////////////////////////////////////////////////// /*
#include
int main(void) // a simple program {
int num; // define a variable called num num = 1; // assign a value to num
printf(\ printf(\
printf(\
return 0; }*/
////////////////////////////////////////////////////////////////// // two_func.c -- a program using two functions in one file /*
#include
void butler(void); // ISO/ANSI C function prototyping int main(void) {
printf(\ butler();
printf(\
return 0; }
void butler(void) // start of function definition {
printf(\} */
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
//
/*
// altnames.c -- portable names for integer types #include
#include
int16_t me16; // me16 a 16-bit signed variable
me16 = 4593;
printf(\ printf(\
printf(\ printf(\ printf(\
return 0;
chapter 03 数据和C
} */
////////////////////////////////////////////////////////////////// /*
// bases.c--prints 100 in decimal, octal, and hex #include
int x = 100;
printf(\ printf(\ //%# 十六进制前显示 Ox //八进制数前显示o return 0; } */
////////////////////////////////////////////////////////////// /*
// charcode.c-displays code number for a character #include
char ch;
printf(\ scanf(\
printf(\
return 0; } */
////////////////////////////////////////////////////////////// /*
//print1.c-displays some properties of printf() #include
int ten = 10; int two = 2;
printf(\
printf(\ printf(\
printf(\ // forgot 2 arguments
return 0; } */
////////////////////////////////////////////////////////////// /* print2.c-more printf() properties */ /*
#include
unsigned int un = 3000000000; // system with 32-bit int short end = 200; // and 16-bit short long big = 65537;
long verybig = 12345678908642;
//C也可以使用前缀h来表示short类型。
//因此%hd显示一个十进制的short整型。%ho为八进制形式。
printf(\ printf(\ printf(\
printf(\
return 0; } */
//////////////////////////////////////////////////////////////
/* showf_pt.c -- displays float value in two ways */ /*
#include
float aboat = 32000.0; double abet = 2.14e9; long double dip = 5.32e-5;
printf(\ printf(\ printf(\
return 0; } */
////////////////////////////////////////////////////////////// /* toobig.c-exceeds maximum int size on our system */ /*
#include
int i = 2147483647;
unsigned int j = 4294967295;
printf(\ printf(\
return 0; } */
////////////////////////////////////////////////////////////// /* typesize.c -- prints out type sizes */ /*
#include
// c99 provides a %zd specifier for sizes
printf(\ printf(\ printf(\ printf(\ return 0; } */
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
//
chapter04 字符串的格式化输入/输出// defines.c -- uses defined constants from limit.h and float. useful ,you can know some limits of the system /*
#include
#include
printf(\ printf(\
printf(\
// this is