資源簡介
隨書源碼
PART ONE
Preliminaries 1
1 An Overview of ANSI C
1.1 What is C?
1.2 The structure of a C program
1.3 Variables,values ,and types
1.4 Expressions
1.5 Statements
1.6 Functions
2 Data Types in C
2.1 Enumeration types
2.2 Data and memory
2.3 Pointers
2.4 Arrays
2.5 Pointers and arrays
2.6 Records
代碼片段和文件信息
/*
?*?File:?addlist.c
?*?---------------
?*?This?program?adds?a?list?of?numbers.??The?end?of?the
?*?input?is?indicated?by?entering?a?sentinel?value?which
?*?is?defined?by?setting?the?value?of?the?constant?Sentinel.
?*/
#include?
#include?“genlib.h“
#include?“simpio.h“
/*
?*?Constants
?*?---------
?*?Sentinel?--?Value?that?terminates?the?input?list
?*/
#define?Sentinel?0
/*?Main?program?*/
main()
{
????int?value?total;
????printf(“This?program?adds?a?list?of?numbers.\n“);
????printf(“Use?%d?to?signal?the?end?of?list.\n“?Sentinel);
????total?=?0;
????while?(TRUE)?{
????????printf(“???“);
????????value?=?GetInteger();
????????if?(value?==?Sentinel)?break;
????????total?+=?value;
????}
????printf(“The?total?is?%d\n“?total);
}
評論
共有 條評論