c語言中單詞編譯
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>#define szWORD 32
#define szSTRN 224
#define szITEM sizeof(struct TItem)
char fileDict[szSTRN];typedef struct TItem {
char word[szWORD];
char mean[szSTRN];
} Item;fpos_t lookup(char *word, char *mean)
{
FILE * f = 0; Item i;
int r = 0; fpos_t p = 0;
if(!word) return 0;
f = fopen(fileDict, "rb");
if (!f) return 0;
while(!feof(f)) {
fgetpos(f, &p);
r = fread(&i, szITEM, 1, f);
if(r < 1) break;
if(i.word[0] == 0) continue;
if(strcmp(i.word , word)) continue;
if(mean) strcpy(mean, i.mean );
fclose(f);
return p+1;
}
fclose(f);
return 0;
}void append(void)
{
Item i; FILE * f = 0; fpos_t p = 0;
memset(&i, 0, szITEM);
printf("請輸入單詞:"); scanf("%s", i.word );
p = lookup(i.word, 0 );
if(p) {
printf("字典內已經有該單詞記錄!\n");
return;
}
printf("請輸入釋義,按回車結束:");
fflush(stdin);
gets(i.mean );
f = fopen(fileDict, "ab");
fwrite(&i, szITEM, 1, f);
fclose(f);
printf("詞條已新增\n");
}void erase(void)
{
Item i; FILE * f = 0; fpos_t p = 0;
memset(&i, 0, szITEM);
printf("請輸入單詞:"); scanf("%s", i.word );
p = lookup(i.word, 0 );
if(p==0) {
printf("字典內沒有該單詞記錄!\n");
return;
}
p--;
memset(&i, 0, szITEM);
f = fopen(fileDict, "rb+");
fsetpos(f, &p);
fwrite(&i, szITEM, 1, f);
fclose(f);
printf("詞條已刪除\n");
}void edit(void)
{
Item i; FILE * f = 0; fpos_t p = 0;
memset(&i, 0, szITEM);
printf("請輸入單詞:"); scanf("%s", i.word );
p = lookup(i.word, 0 );
if(p==0) {
printf("字典內沒有該單詞記錄!\n");
return;
}
p--;
printf("請輸入釋義,按回車結束(輸入abort放棄修改):");
fflush(stdin);
gets(i.mean );
if(strstr(i.mean ,"abort")) {
printf("已放棄修改!\n");
return ;
}
f = fopen(fileDict, "rb+");
fsetpos(f, &p);
fwrite(&i, szITEM, 1, f);
fclose(f);
printf("詞條已保存\n");
}void query(void)
{
Item i; fpos_t p = 0;
memset(&i, 0, szITEM);
printf("請輸入單詞:"); scanf("%s", i.word );
p = lookup(i.word, i.mean );
if(p==0) {
printf("字典內沒有該單詞記錄!\n");
return;
}
printf("【詞條】%s\n【釋義】%s", i.word , i.mean );
}void set(void)
{
int cmd = 0;
printf("當前字典為%s,需要改變嗎(選擇y或Y改變)?", fileDict);
cmd = getch();
if(cmd == 'y' || cmd == 'Y') {
printf("請輸入字典文件名稱(包含路徑):");
scanf("%s", fileDict);
printf("設置成功!\n");
}
}
int main(int argc, char * argv[])
{
int cmd = 0;
if(argc >1)
strcpy(fileDict, argv[1]);
else
strcpy(fileDict, "c:\\dict.txt");
/*end if*/
for(;;) {
printf("\n\
************************\n\
** 歡迎使用迷你字典!**\n\
************************\n\
** 0 - 設置字典 **\n\
** 1 - 查詢詞條 **\n\
** 2 - 新增詞條 **\n\
** 3 - 編輯詞條 **\n\
** 4 - 刪除詞條 **\n\
** 5 - 退出字典 **\n\
************************\n");
cmd = getch() - '0';
switch(cmd) {
case 0: set(); break;
case 1: query(); break;
case 2: append(); break;
case 3: edit(); break;
case 4: erase(); break;
default: return 0;
}
}
return 0;
}
2. c語言中編譯是指什麼
哈哈
製作程序過程中,化腐朽為神奇的一步
代碼組成的文本文件(程序員編寫)=>
可執行的文件(最終會被組成EXE之類程序)
3. C語言源程序的編譯過程包括哪三個階段
編譯:將源程序轉換為擴展名為.obj的二進制代碼
連接:將obj文件進行連接,加入庫函數等生成可執行文件
運行:執行可執行文件,有錯返回修改,無錯結束
4. C語言一些單詞
C語言常用單詞 2009-02-04 16:14 演算法 algorithm 機器語言machine language
運算與邏輯單元ALU 內存單元 memory unit
分析 analysis 微處理器microprocessor
應用軟體application software 模型model
匯編程序assembler
面向對象的語言object-oriented language
匯編語言assembler language 操作碼opcode
備份件backup copies 操作系統operating system
位bit
面向過程的語言procere-oriented language
引導boot 程序設計progremming
位元組bytes 匯編語言programming language
偽代碼pseudocode 類class
細化refinement 編寫代碼coding
循環結構repetition 編譯型語言compiled language
編譯程序compiler 輔存secondary storage
計算機程序computer program 選擇結構selection
控制單元 control unit 順序結構sequence
文檔編寫documentation 軟體software
軟盤floppy diskette
軟體開發過程software development procere
流程圖flowchart 軟體工程software engineering
硬碟hard disk 軟體維護software maintenance
硬體hardware 源代碼soure code
高級語言high-level language 源程序source program
輸入/輸出單元 I/O unit 語法syntax
調用invocation 系統軟體system software
循環結構iteration 測試testing
解釋型語言interpreted language二進制補碼two』s complement
解釋程序interpreter 低級語言low-level language抽象abstraction 累加accumulating
參數argument 自減運算符decrement operator
算術運算符arithmetic operators 參數argument
賦值語句assignment statement 賦值運算符assignment operators
綜合性associativity 類型轉換cast
原子數據類型atomic data value 編譯時錯誤compile-time error
字元值character values 記數counting
類class 對齊justificating
注釋comments 邏輯錯誤logic error
數據類型data type 左值lvalue
聲明語句declaration statement 魔術數magic number
定義語句definition statement 數學頭文件mathematical library
雙精度數double-precision number 八進制octal
轉義序列escape sequence 已命名常數named constant
表達式expression 桌面檢查desk checking
浮點數floating-point number 域寬操縱符field width manipulator
函數function 回顯列印echo printing
頭文件header file 十六進制hexadecimal
標識符identifier
程序驗證與測試program verification and testing
整數值iteger value 自增運算符 increment operator
關鍵字keyword 實現implement
操縱符manipulator 提示prompt
混合表達式mixed-mode expression 運行時錯誤run-time error
助記符mnemonic 右值rvalue
模塊mole 符號常數symbolic constant
取模運算符molus operator 語法錯誤syntax error
優先順序 preccedence 跟蹤tracing
變數variable 類型轉換type conversions 1.保留字:
C語言的關鍵字共有32個,根據關鍵字的作用,可分其為數據類型關鍵字、控制語句關鍵字、存儲類型關鍵字和其它關鍵字四類。
(1)數據類型關鍵字(12個):char, double, enum, float, int, long, short, signed, struct, union, unsigned, void
(2)控制語句關鍵字(12個):break, case, continue, default, do, else, for, goto, if, return, switch, while
(3)存儲類型關鍵字(4個):auto, extern, register, static
(4)其它關鍵字(4個):const, sizeof, typedef, volatile
2.控制語句:
控制語句完成一定的控制功能。C語言只有9條控制語句,又可細分為三種:
( 1)選擇結構控制語句
if()~else~, switch()~
(2)循環結構控制語句
do~while(), for()~, while()~, break, continue
(3)其它控制語句
goto, return
3。函數:
字元串函數
bcmp
b
bzero
memccpy
memchr
memcmp
memcpy
memicmp
memmove
memset
movmem
setmem
stpcpy
strcat
strchr
strcmp
strcmpi
strcpy
strcspn
strp
stricmp
strlen
strlwr
strncat
strncmp
strncmpi
strncpy
strnicmp
strpbrk
strrev
strset
strstr
strtok
strupr
數學函數
abs
acos
asin
atan
atan2
ceil
cos
cosh
exp
fabs
floor
fmod
frexp
hypot
ldexp
log
log10
modf
pow
pow10
sin
sinh
sqrt
tan
tanh
輸入輸出函數
getchar
kbhit
printf
putchar
系統庫函數
ClearScreen
DispBCD
SetScrollBar
TextOut
UpdateLCD
bell
block
clrscr
cursor
delay
get_chi_font
get_eng_font
getkey
getpixel
gotoxy
line
move
noidle
outtextxy
putpixel
pyfc
rectangle
sleep
textmode
time
write_chi_font
write_eng_font
標准函數
exit
itoa
字元函數
isalnum
isalpha
iscntrl
isdigit
islower
isascii
isgraph
isprint
ispunct
isspace
isupper
isxdigit
toascii
tolower
toupper
動態內存分配函數
calloc
free
malloc
realloc 讀音要有一定的英語基礎...基本上到4級...下個金山詞霸或著有道...也有一定幫助!
5. 問C語言編程所涉及英文單詞或函數的中英文對照表
1. 數據定義
C語言中所有的變數都具有某種類型,其定義的基本格式是:類型 變數名; int:整型 short:短整型 long:長整型 signed:有符號型 unsigned:無符號型 char:字元型 float:單精度型 double:雙精度型 const:定義常量 typedef:類型定義
2. 存儲類別
一般在變數的定義前面,用於指定變數的存儲類別,如果預設的話,則默認是auto。 auto:自動變數 static: 靜態變數 register:寄存器變數 extern:外部變數
3. 結構
C語言中除了提供一些基本數據類型外,還提供了結構體,共有體以及枚舉,用來實現多個變數的集合表示。 struct:結構體 union:共用體 enum:枚舉類型
4. 語句
C語言中提供了一些語句來實現程序的基本結構。 if:條件判斷(假如) else:不滿足條件(否則) for:循環
do:與while一起使用,直到型循環 while:當型循環 goto:無條件跳轉語句 switch:多分支選擇語句
case:分支,在switch語句塊中表示不同的分支 default:預設,一般在switch語句中使用 continue:繼續(結束本次循環) break:中斷(跳出整個循環) return:返回
void:空類型(用於函數沒有返回值時)
5. 預處理
#define:定義一個宏名來代替一個字元串 #include:引入程序所需要的頭文件 #undef:條件編譯 #ifdef:假如定義 #ifndef:假如沒有定義
6. c語言必背單詞
1.return返回。2.value值。3.function函數。4.declaration聲明。5.extern外部。6.insert插入。7.error錯誤。8.delete刪除。9.file文件。10.open打開。11close關閉。12.read讀。13.write寫。14.constant常量。15.number數字。16.circle循環。17.variant變數。18.sort排序。19.keywords關鍵字。20.debug調試。暫時就列出來20個非常常用的c語言必背單詞,使用編程語言會經常遇到這些單詞的,望採納。
7. c語言編程所用到的全部英語單詞
就32個英語單詞。如下參考:
1、數據類型關鍵字(8個)int 、short 、long、signed、unsigned、char 、float,、double
2、程序控制關鍵字(10個)
if 、else、switch、case、default、break、do 、while、 for、continue
3、函數及數據存儲關鍵字(6個)
void 、return、auto、register、static、 extern
4、構造數據類型關鍵字(5個)
struct、union、enum、typedef、sizeof
5、其它3個不常用(3個)
goto、const、 volatile
(7)c語言中單詞編譯擴展閱讀:
1、如果要定義一個存放20個英文的字元串,數組的長度應該是20+1,原因以後再討論。
2、一個中文漢字或全形的標點符號需要兩個字元寬度來存放。
3、變數名中的字母是區分大小寫的。比如 a 和 A 是不同的變數名,num 和 Num 也是不同的變數名。
4、include用法:
#include命令預處理命令的一種,預處理命令可以將別的源代碼內容插入到所指定的位置;可以標識出只有在特定條件下才會被編譯的某一段程序代碼;可以定義類似標識符功能的宏,在編譯時,預處理器會用別的文本取代該宏。
5、插入頭文件的內容
include命令告訴預處理程序將指定頭文件的內容插入到預處理程序命令的適當位置。有兩種方法來指定插入頭文件:
# include<文件名& gt;
#包括「文件名稱」
如果需要包含標准庫標頭或實現版本提供的標頭,則應使用第一種格式。
8. (C語言編程)輸入一個英文句子,將每個英文單詞的頭字母變為大寫,單詞之間用空格隔開
程序已在dev-c++下編譯確認:/*提取用空格分隔的字元串中的單詞,並改單詞首字母為大寫*/
#include<stdio.h>
int partition(char *s1,char *s2,int pos)
{
int i,j;
i=pos;
while(s1[i]==' ')
i++;
if(s1[i]!='