Click here to load reader

書名:輕鬆學習 C 語言 TOC

Embed Size (px)

DESCRIPTION

書名:輕鬆學習 C 語言 TOC. 作者:陳澤雄、蕭宗志、林國任、黃珮瑩、黃佑民 出版社:旗標出版股份有限公司 ICT: 2-9,12,14,18-152,160,167-201, 248,250,252,254,255,258-261,264,266,268,270,274, 279-282. 第一章 C 語言簡介. 1-1 C 語言的結構 1-2 識別字 // identifier 1-3 關鍵字 // reserved words 1-4 註解 // comments/* remarks */ - PowerPoint PPT Presentation

Citation preview

C

31-1 CC // test.c#include/**/

int main(){ /**/ system("pause"); // return 0;}// test.cpp#includeusing namespace std;int main(){system("pause"); return 0;}4int i, n, sum=1;//printf("The input number =");scanf("%i", &n);

for (i=1; i 1 = %i \n", b);8 }(Bitwise Operator)73&i & ji AND j|i | ji OR j^i ^ ji XOR j~~ iNOT i74 Ch4_3 1 #include 2 main(){ 3int A = 3, B = 5;Ch4_3 A & B = 1A | B = 7A ^ B = 6~A = -4 4printf("A & B = %i \n", A & B); 5printf("A | B = %i \n", A | B); 6printf("A ^ B = %i \n", A ^ B); 7printf(" ~A = %i \n", ~A ); 8 }75Ch4_3 0011(2) 3(10) 0101(2) 5(10) 0001(2) 1(10)&(AND) 0011(2) 3(10) 0101(2) 5(10) 0111(2) 7(10) |(OR) 0011(2) 3(10) 0101(2) 5(10) 0110(2) 6(10)^(XOR)(Relational Operator) 76>a>ba>bj);5 printf ("%i< %i = %i\n", i,j, i=j);7printf ("%istr2");8 }1cpu2mousestr1str21969-3-3 strcpy() strcpy (1, 2);122121()

// str1str2197Ch9_115printf("2 ");6gets(str2);2newstr1original1newstr7printf("1%s\n", str1);8strcpy(str1, str2);9printf("1%s\n", str1);ch9_11 2214char str1[30] = "original", str2[30];198strcat (str1, str2); // str1str1+str2 str1str2str2str1'\0''\0'9-3-4 strcat()str2199Ch9_12ch9_12 strcat()1 #include2 #include3 main(){4 char str1[20]="Open ";5 char str2[20]="University"; str1= Open str1= Open University6 printf("str1=%s\n", str1);7 strcat (str1, str2);8 printf("str1=%s\n, str1);9 } 2009-3-5 toupper()tolower() = tolower(); = toupper();

ctype.htoupper(c)ctolower(c)c201Ch9_1311 printf(" ");12 gets(str2);131415 printf(" %s\n", str2);16 }1 #include2 #include3 main(){4 int i;5 char str1[10], str2[10];6 printf(" ");7 gets(str1);890 printf(" %s\n", str1); eFg

ABCd

for (i=0; str1[i] != '\0'; i++)str1[i] = tolower( str1[i] ); abcdfor (i=0; i