C语言学习(英文版)优秀讲义
Chapter 1 Getting Started of C School of Software, Nanchang HangKong University * Chapter 1 Getting Started of C Outline 1.1 Programming, Compilation and Execution 1.2 The First C program 1.3 Another Simple C Program: Adding Two Integers 1.4 Basic Operations of TC The only way to learn a new programming language is by writing programming in it. Outline Key points The Basic Structure of C Program The Basic Operations of TC 1.1 Programming, Compilation and Execution The Editor can be used to type the C program. The complier convert the typed program to machine language. The principal text editor on the UNIX system is called vi. Some systems, such as Turbo C and Borland C++, integrate the text editor and the compiler. 1.2 The first C Program 1/*A first program in C */ 2 3#include 4 5int main() 6{ 7 printf( "Welcome to C!\n" ); 8 9 return 0; 10} Welcome to C! 1.2 The first C Program Comments Text enclosed within /* */, completely ignored by the compiler. Can be written at any place in the program Are essential when building big software Cannot be nested. /* /* */ */ is invalid. Can be split over more than one line. 1.2 The first C Program #include Preprocessor directive(\) Tells computer to load contents of a certain file allows standard input/output operations int main() C programs contain one or more functions, exactly one of which must be main Parenthesis used to indicate a function int means that main "returns" an integer value Braces ({ and }) indicate a block The bodies of all functions must be contained in braces 1.2 The first C Program A C program,whatever its size,consists of functions and variables. 1.2 The first C Program printf( "Welcome to C!\n" ); Instructs computer to perform an action Specifically, prints the string of characters within quotes (“ ”) Entire line called a statement All statements must end with