1、MicrosoftVisualC++是微软公司的免费C语言编程软件,是用户在安装VisualC++库时必须安装的运行时组件,可以完美解决在系统运行一些软件时会遇到缺少DLL的情况,使用户可正常运行VisualC++开发的应用程序。
2、myeclipse是款优秀的JAVA开发工具,MyEclipse功能强大,运用广泛,尤其是对各种开源产品的支持十分不错,能够大大提高开发人员的工作效率。
3、TurboC是一款功能快捷高效的C语言编辑器,主要是用来编写C/C++程序,无需独立地编辑、编译和连接程序就能建立并运行C语言程序,软件体积非常的小巧,并且对于电脑方面没有特别的系统要求,功能上也十分的强大。
4、gcc编译器是款专业的c语言编辑工具,可用于c语言、c++、java、object-C等语言程序中去,支持交叉编译器,交叉语言设计,提供交叉编译环境,通过在命令列下键入一些命令参数,让编程更有效率。
总结
c语言可以用的编译器有很多,包括MicrosoftVisualC++、MyEclipse、TurboC和gcc编译器等。
/*c语言程序设计 简单的行编辑器
【要求】
(1) 设置一个简单的行编辑器,每行以回车结束
(2) 数据以文件形式存储
(3) 编辑器具有查找、替换、修改数据的功能
【备注】完全原创,编写时间:2010-7-13。请把所有的注释信息提取出来就可以写程序设计报告。
*/
#include /*标准文件流操作,这里使用了fopen/fclose/fprintf/printf/scanf/gets函数*/
#include /*标准系统库,这里使用了malloc/free/exit*/
#include /*标准字符串库,这里使用strlen/strcpy/memcpy/memset*/
#define szLINE 252 /*定义一行字符串最长为252字节*/
#define CMDS 12 /*定义12个标准行编辑命令*/
/*采用链表存储文本*/
typedef struct LINE {
char text[szLINE]/*文本内容*/
struct LINE * next/*链表指针*/
} L
/*简写无类型整数*/
typedef unsigned int U
/*定义12个行编辑命令的标准格式*/
typedef void (*FUNC)(L **, char*)
/*定义12个标准行编辑命令的关键字*/
char keywords[CMDS][8]={
"quit", "help", "load", "save",
"view", "count", "append", "insert",
"erase", "edit", "lookup", "replace"
}/*end keywords*/
/*清空链表操作*/
void clear(L ** lines)
{
L * a = 0, * b = 0
if(!lines) return
a = *lines
while(a) {
b = a->next
free(a)
a = b
}/*end while*/
*lines = 0
}/*end clear*/
/*在链表中根据行号index调出指定的行*/
L * locate(L * lines, U index)
{
L * t = linesU i = 0
if(!t) return 0
if(index == 0) return t
for(i = 0i <indexi++) {
t = t->next
if(!t) return 0
}/*next*/
return t
}/*end locate*/
/*浏览命令,如果f存在则以带行号格式保存文件(如果f==stdout则打印到屏幕上),
浏览范围为from到to(行号)。view(lines, 0, 0, 0)表示统计已加载到内存的文本行数量*/
int view(L * lines, FILE * f, U from, U to)
{
L * t = linesU index = 0
while(t) {
index ++
if(f &&index >= from &&index text)
t = t->next
}/*end while*/
return index
}/*end view*/
/*在当前文档中根据关键字进行搜索,并将搜索结果打印出来*/
void lookup(L * lines, char * string)
{
L * t = 0U index = 0
if(!string) return
t = lines
while(t) {
index ++
if(strstr(t->text , string)) printf("%d: %s", index, t->text )
t=t->next
}/*end while*/
}/*end lookup*/
/*在一行文本中执行替换命令,把所有关键字替换为新关键字*/
void rpc(char * string, char * key, char * replacement)
{
char fine[szLINE], * x = 0, * y = 0, * z = 0
int la = 0, lb = 0, r = 0
if(!string || !key || !replacement) return
memset(fine, 0, szLINE)
x = stringy = fine
/*首先记录新旧关键字长度*/
la = strlen(key)
lb = strlen(replacement)
do {
/*用指针逐个比较*/
r = memcmp(x, key, la)
if(r) {/*如果关键字不匹配则复制字符串*/
*y = *x
x++y++
}else{/*如果关键字匹配则替换字符串*/
memcpy(y, replacement, lb)
x += lay += lb
}/*end if*/
}while(*x)
/*将替换完成的结果返回*/
memcpy(string, fine, szLINE)
}/*end rpc*/
/*全文替换*/
void replace(L * lines, char * string, char * replacement)
{
L * t = 0U index = 0
if(!string || !lines || !replacement) return
t = lines
while(t) {
index ++
if(strstr(t->text , string)) {
printf("[BEFORE] %d: %s", index, t->text )
rpc(t->text, string, replacement)
printf("[AFTER ] %d: %s", index, t->text )
}/*end if*/
t=t->next
}/*end while*/
}/*end replace*/
/*根据行号插入一行新文本,如果行号小于零则将文本追加至链表尾*/
void insert(L ** lines, char * line, int index)
{
L * t = 0, * s = 0int i = 0
if(!lines || !line) return
/*首先为新文本分配一个链表节点*/
t = (L*)malloc(sizeof(L))
memset(t, 0, sizeof(L))
strcpy(t->text , line)
if(index == 0 || !*lines) {/*如果链表为空则以新节点为起点定义链表*/
t->next = *lines
*lines = t
return
}/*end if*/
s = *lines
if(index >0)/*如果行号为正整数,则将链表指针指向行号之前*/
for(i = 0i <index-2i++) {
if(!s->next ) break
s = s->next
}/*next*/
else/*否则链表指针指向表尾*/
while(s->next ) s = s->next
/*end if*/
/*完成链表插入操作*/
if(s->next ) t->next = s->next
s->next = t
}/*end insert*/
/*根据行号删除一行文本*/
void erase(L ** lines, U index)
{
L * a = 0, * b = 0, * c = 0
if(!lines) return
/*index -1 表示目标行,index -2表示目标行的前一行*/
a = locate(*lines, index-2)
b = locate(*lines, index-1)
if(!b) return
if(a) /*如果前一行存在则删除目标行*/
a->next = b->next
else/*否则表示表头删除*/
*lines = b->next
/*end if*/
/*释放内存*/
free(b)
}/*end erase*/
/*根据行号和新录入文本替换原有行*/
void edit(L * lines, char * line, U index)
{
L * t = locate(lines, index-1)
if(!t) return
if(line) strcpy(t->text , line)
}/*end edit*/
/*将文件整个装入链表*/
int load(L ** lines, char * file)
{
FILE * f = 0char line[szLINE]=""
int total = 0
if(!lines || !file) return 0
clear(lines)/*首先清空链表*/
/*打开文件*/
f = fopen(file, "r")
if(!f) {
fprintf(stderr, "%s is bad.\n", file)
return 0
}/*end if*/
/*逐行读入内存并插入表尾*/
while(!feof(f)) {
memset(line, 0, szLINE)
fgets(line, szLINE - 1, f)
insert(lines, line, -1)
total ++
}/*end while*/
fclose(f)
fprintf(stderr, "[%s] %d lines loaded.\n", file, total)
/*返回总行数*/
return total
}/*end load*/
/*将链表保存到指定的文本文件*/
int save(L * lines, char * file)
{
FILE * f = 0L * t = lines
int total = 0
if(!lines || !file) return 0
/*打开文件*/
f = fopen(file, "w")
if(!f) {
fprintf(stderr, "%s is bad.\n", file)
return 0
}/*end if*/
t = lines
while(t) {/*逐个文件写入*/
fprintf(f, "%s", t->text )
t = t->next
total ++
}/*end while*/
fclose(f)
fprintf(stderr, "[%s] %d lines saved.\n", file, total)
/*返回总行数*/
return total
}/*save*/
/*执行加载文本文件命令*/
void exec_load(L ** lines, char * line)
{
char cmd[szLINE] = "", file[szLINE] = ""
/*分析命令行,提取文件名*/
sscanf(line, "%s %s", cmd, file)
/*执行加载命令*/
load(lines, file)
}/*end exec_load*/
/*执行文本保存命令*/
void exec_save(L ** lines, char * line)
{
char cmd[szLINE] = "", file[szLINE] = ""
/*分析命令行,提取文件名*/
sscanf(line, "%s %s", cmd, file)
/*执行保存命令*/
save(*lines, file)
}/*end exec_save*/
/*执行文本查看命令*/
void exec_view(L ** lines, char * line)
{
char cmd[szLINE] = ""U from = 0, to = 0
/*分析命令行,提取目标要查看的起始行号和终止行号*/
sscanf(line, "%s %u %u", cmd, &from, &to)
/*如果起始行号和终止行号大小相反,则根据起始行号显示一页*/
if(to <from) to = from + 24
/*执行查看命令*/
view(*lines, stdout, from, to)
}/*end exec_view*/
/*执行行数统计命令*/
void exec_count(L ** lines, char * line)
{
fprintf(stderr, "%d lines in mem.\n", view(*lines, 0, 0, 0))
}/*end count*/
/*执行文本追加命令*/
void exec_append(L ** lines, char * line)
{
char text[szLINE] = ""
/*在命令之后另起新行用于录入文本*/
gets(text)strcat(text, "\n")
/*执行文本追加命令*/
insert(lines, text, -1)
}/*end exec_append*/
/*执行文本插入命令*/
void exec_insert(L ** lines, char * line)
{
char cmd[szLINE] = "", text[szLINE] = ""U index = 0
/*从命令行提取目标插入点的行号*/
sscanf(line, "%s %d", cmd, &index)
/*在命令之后另起新行用于录入文本*/
gets(text)strcat(text, "\n")
/*执行文本插入命令*/
insert(lines, text, index)
}/*end insert*/
/*执行文本删除命令*/
void exec_erase(L ** lines, char * line)
{
char cmd[szLINE] = ""U index = 0
/*从命令行提取目标行号*/
sscanf(line, "%s %d", cmd, &index)
/*执行文本删除命令*/
erase(lines, index)
}/*end erase*/
/*执行文本编辑命令*/
void exec_edit(L ** lines, char * line)
{
char cmd[szLINE] = "", text[szLINE] = ""U index = 0
/*从命令行提取目标行号*/
sscanf(line, "%s %d", cmd, &index)
/*在命令之后另起新行用于录入文本*/
gets(text)strcat(text, "\n")
/*执行文本编辑命令*/
edit(*lines, text, index)
}/*end edit*/
/*执行文本检索命令*/
void exec_lookup(L ** lines, char * line)
{
char cmd[szLINE] = "", text[szLINE] = ""
/*从命令行提取关键字*/
sscanf(line, "%s %s", cmd, text)
/*执行文本检索命令*/
lookup(*lines, text)
}/*end lookup*/
/*执行在线帮助命令*/
void exec_help(L ** lines, char * line)
{printf("\tcommands:\n\thelp\n\tquit\n\
\tload [file.txt]\n\
\tsave [file.txt]\n\
\tview [from line] [to line]\n\
\tcount\n\
\tappend [return + text]\n\
\tinsert [line number] [return + text]\n\
\terase [line number]\n\
\tedit [line number] [return + text]\n\
\tlookup [text]\n\
\treplace [keyword] [replacement]\n")
}/*end help*/
/*执行文本替换命令*/
void exec_replace(L ** lines, char * line)
{
char cmd[szLINE] = "", text[szLINE] = "", key[szLINE]=""
/*从命令行提取新旧关键字*/
sscanf(line, "%s %s %s", cmd, key, text)
/*执行文本替换命令*/
replace(*lines, key, text)
}/*end replace*/
/*执行退出命令*/
void exec_quit(L ** lines, char * line){exit(0)}
/*行编辑命令执行函数,顺序与关键字表keywords一一对应*/
FUNC functions[CMDS]={
exec_quit, exec_help, exec_load, exec_save,
exec_view, exec_count, exec_append, exec_insert,
exec_erase, exec_edit, exec_lookup, exec_replace
}/*end functions*/
/*从行输入中识别关键字,相当于parse*/
int identified(char * command, char * key)
{
int ln = 0, r = 0
if(!command || !key) return 0
ln = strlen(key)
r = memcmp(command, key, ln)
return r==0
}/*end identified*/
/*主函数*/
int main(int argc, char * argv[])
{
L * lines = 0char line[szLINE]=""int a = 0, b = 0, i = 0FUNC fun = 0
/*打印欢迎信息*/
printf("Welcome to LINE EDITOR V1.0\nCommand [help] is available.\n")
/*如果带主函数带参数,则可以用于打印帮助,或者根据该参数加载一个文本文件*/
if(argc >1) {
a = strcmp(argv[1], "--help")
b = strcmp(argv[1], "/h")
if(a &&b)
load(&lines, argv[1])
else{
exec_help(0, 0)
return 0
}/*end if*/
}/*end if*/
/*主命令循环*/
for() {
/*命令提示符中间是表示当前载入的文档总共有多少行的意思*/
printf("\n
C语言的代码编辑器一般使用UE,以下介绍UE的使用方法:1、在UE上用的最多的是c语言,这里,就以c语言作为参考,看看UE的强大的操作功能。打开一个c语言文件。文件-- 打开--选择。
2、这个时候,可以看到它的函数功能和上面的快捷方式的图标是可以使用的。函数列表可以在视图--视图列表--函数列表中找到。
3、然后,可以使用ue的查看方式,这里是默认为c语言格式,还可以设置为c#,java等格式,这样可以把部分信息高亮显示。还可以在:视图 --- 查看方式-----编码方式中找到。
4、比较功能和16进制功能,这个是很强大的工具。因为,在上线的时候,不知道修改了什么就可以使用这个进行查看,还有,在linux下炒作的时候,16进制就可以看到文件中的字符编码,找到最终的错误原因。
5、还有就是ue的列模式,这个模式对于编程来说,简直逆天,当有些数据需要进行修改的时候,只是改某些列中的部分,这个就非常好用了。直接修改多列。这也是ue的一个特色吧。
6、强大的FTP功能,一般可以使用ue直接在ftp服务器上直接编辑文件,然后,直接保存在服务器上,这样呢,可以减少代码的本地管理和版本控制。
7、普通文件操作可以在快捷方式中使用新建,保存等功能,可以使用字数统计功能,具体的字数在状态栏中有显示。