当前位置:首页 » 编程软件 » c语言中单词编译

c语言中单词编译

发布时间: 2022-07-13 22:46:51

1. 如何用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]!='')

{

j=0;

s2[j]='';

s2[0]=toupper(s2[0]);

return i;

char string[256];

char partition_string[20];

int position;

int k;

printf(" Please input a string:");

printf(" ");

system("pause");

return 0;

}

简洁的语言

C语言包含的各种控制语句仅有9种,关键字也只有32个,程序的编写要求不严格且以小写字母为主,对许多不必要的部分进行了精简。实际上,语句构成与硬件有关联的较少,且C语言本身不提供与硬件相关的输入输出、文件管理等功能,如需此类功能,需要通过配合编译系统所支持的各类库进行编程,故c语言拥有非常简洁的编译系统。

以上内容参考:网络-c语言

9. 用C语言实现单词转换

****************************
FileName: WordCount.cpp
Author: cox Version : 1.0 Date: 2007/1/12
Description: 文件中指定单词个数的统计
Version: 1.0
Function List:
1. TransformFile() // 将文件转换为有效的格式
2. CountWord() // 单词计数
3. IsValidChar() // 检查是否有效的英语字母
4. GetInput() // 从输入流读取数据
5. UpperCase() // 字符强制转换为大写
History:
<author> <time> <version > <desc>
cox 2007/1/12 1.0 build this moudle
***************************************************/

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#include "linklist\\linklist.h"

bool TransformFile( char* inFile, char* outFile );
template <typename datatype>
bool CountWord( char* filename, LinkList<datatype> &list );
bool IsValidChar( char ch );
template <typename datatype>
bool GetInput( LinkList<datatype> &list );
bool UpperCase( string &str );

/*************************************************
Function: main()
Description: 主函数
Calls: 链表类, TransformFile(), GetInput(),
CountWord()
Called By: 无
Table Accessed: 无
Table Updated: 无
Input: 无
Output: 结果
Return: 0
Others: 无
*************************************************/
int main()
{
LinkList<string> wordList;

TransformFile( "test1.txt", "test1.tmp" );
if ( !GetInput( wordList ) )
{
cout << "Bad input!!" << endl;
}
if ( !CountWord( "test1.tmp", wordList ) )
{
cout << "An error accord dring count!!" << endl;
}

return 0;
}

/*************************************************
Function: TransformFile()
Description: 将文件去掉标点符号, 并按照单词以空格分组
Calls: IsValidChar()
Called By: main()
Table Accessed: 无
Table Updated: 无
Input: char* inFile // 输入文件名
char* outFile // 输出文件名
Output: 状态
Return: 操作是否成功
Others: 无
*************************************************/
bool TransformFile( char* inFile, char* outFile )
{
ofstream outFileStream( outFile, ios::out );
ifstream inFileStream ( inFile , ios::in );

if ( !outFileStream || !inFileStream )
{
cout << "Open files error!!" << endl;
return false;
}

char readChar = '\0';
cout << "Transfroming...";
// 转换
while ( inFileStream.get(readChar) )
{
if ( IsValidChar(readChar) )
{
outFileStream << readChar;
}
else
{
outFileStream << " ";
}
}
cout << "OK\n";

outFileStream.close();
inFileStream.close();
return true;
}

/*************************************************
Function: IsValidChar()
Description: 检查是否有效的英语字符
Calls: 无
Called By: TransformFile()
Table Accessed: 无
Table Updated: 无
Input: char ch // 待检查的字符
Output: 无
Return: true为是
Others: 无
*************************************************/
bool IsValidChar( char ch )
{
if ( (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) )
{
return true;
}
else
{
return false;
}
}

/*************************************************
Function: GetInput()
Description: 读取输入流并存入链表中
Calls: 链表类
Called By: main()
Table Accessed: 无
Table Updated: 无
Input: LinkList<datatype> &list // 储存输入数据的链表
Output: 无
Return: 操作是否成功, true为成功
Others: 无
*************************************************/
template <typename datatype>
bool GetInput( LinkList<datatype> &list )
{
string strInput = "";

cout << "Input your words to count, split by \',\': ";
cin >> strInput;

string tmpString = "";
strInput += ",";
for ( int index = 0; index < strInput.size(); index++ )
{
if ( strInput[index] == ',' )
{
list.Insert(tmpString);
tmpString = "";
}
else
{
tmpString += strInput[index];
}
}

return true;
}

/*************************************************
Function: CountWord()
Description: 单词计数
Calls: 链表类, UpperCase()
Called By: main()
Table Accessed: 无
Table Updated: 无
Input: char* filename // 待计数的文件
LinkList<datatype> &list // 储存输入数据的链表
Output: 无
Return: 操作是否成功, true为成功
Others: 无
*************************************************/
template <typename datatype>
bool CountWord( char* filename, LinkList<datatype> &list )
{
ifstream inFileStream ( filename , ios::in );

int lenth = list.Lenth();
int *counts = new int [lenth];
for ( int clrIndex = 0; clrIndex < list.Lenth(); clrIndex++ )
{
counts[clrIndex] = 0;
}

string tmpString;
string tmpRead;

while ( inFileStream >> tmpRead )
{
for ( int index = 0; index < list.Lenth(); index++ )
{
list.Locate(index+1);
tmpString = list.Peek();

UpperCase( tmpString );
UpperCase( tmpRead );

if ( tmpString == tmpRead )
{
counts[index]++;
}
}
}

for ( int index = 0; index < lenth; index++ )
{
list.Locate(index+1);
tmpString = list.Peek();
cout << tmpString << " = " << counts[index] << endl;
}
cout << endl;
inFileStream.close();
return true;
}

/*************************************************
Function: UpperCase()
Description: 强制转换成大写
Calls: 无
Called By: CountWord()
Table Accessed: 无
Table Updated: 无
Input: string &str // 待转换的字符
Output: 无
Return: 操作是否成功, true为成功
Others: 无
*************************************************/
bool UpperCase( string &str )
{
for ( int index = 0; index < str.size(); index++ )
{
if ( str[index] > 96 )
{
str[index] -= 32;
}
}
return true;
}

需要链表,自己写一个吧,大一就该学了的~~

热点内容
cryengine源码 发布:2025-02-08 09:50:58 浏览:392
aardio可以反编译吗 发布:2025-02-08 09:50:53 浏览:482
公司营业执照密码是什么 发布:2025-02-08 09:47:56 浏览:854
体验脚本 发布:2025-02-08 09:46:15 浏览:690
医学生需要什么配置的笔记本 发布:2025-02-08 09:45:34 浏览:771
骚扰电话数据库 发布:2025-02-08 09:45:34 浏览:179
u盘文件加密器 发布:2025-02-08 09:40:35 浏览:769
plc数据存储app 发布:2025-02-08 09:37:17 浏览:708
服务器的峰值高低有什么区别 发布:2025-02-08 09:35:46 浏览:689
maven预编译 发布:2025-02-08 09:20:34 浏览:755