C电子词典设计

benben_TBAG 2007-04-24 05:37:38
各位CDSN社区里面的成员大家好!我是一个刚刚注册进来的FISH 其实 我也是一个计算机专业的在读大学生 由于最近学校有要求关于C语言的课题设计题目 小弟才疏学浅 学艺不精 于是特来CDSN社区讨教 希望能够得到那位好心的大侠 拔刀相助啊 指点江山啊~~~当面重谢不敢说 不过肯定会十分的感谢你 也十分感谢CDSN社区这个中国最大的 网络社区 同时也希望CDSN社区能够办的越来越好~~
以下为课题题目:
功能要求:
制作一个电子词典:可以输入 查询 删除 修改词条(英文单词 中文或英文解释).
界面要求:
美观简洁.
其实我也已经在 百度 上面找到了一个相关的 源代码附带如下:
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <malloc.h>
#include <winbase.h>
#include <process.h>


void Search()
{
char temp[100];
char buffer[2];
char result[100];
printf("Please input the word you want:\n");
scanf("%s",&temp);
buffer[0]=temp[0];
buffer[1]='\0';
int ret=GetPrivateProfileString(buffer,temp,0,result,100,"./date.ini");
if(ret>0)
printf("%s\n\n\n\n\n",result);
else
printf("Sorry there is not what you want.\n\n\n\n\n");
}

void InsertItem()
{
char temp[100];
char buffer[2];
char result[100];
printf("Inser the word:\n");
scanf("%s",&temp);
printf("Givinig the meaning:\n");
getchar();
scanf("%s",&result);
buffer[0]=temp[0];
buffer[1]='\0';
int ret=WritePrivateProfileString(buffer,temp,result,"./date.ini");
if(ret=0)
printf("Inser fail。\n\n\n\n\n");
else
printf("Inser success。\n\n\n\n\n");
}

int main(int argc, char* argv[])
{
int index;
main:
printf("**************MENU***************\n\n");
printf(" 1 Chinese to English\n");
// printf("2 English to Chinese\n");
printf(" 2 Inser the new word\n");
// printf(" 3 Del the existed word \n");
printf(" 3 Clean the screen\n");
printf(" 4 Exit\n\n");
printf("**********************************\n");
do{
printf("Please chioce form 1 to 4(1~4):\n");
scanf("%d",&index);
}while(index<0||index>5);
switch(index)
{
case 1:
Search();
goto main;
break;
case 2:
InsertItem();
goto main;
break;
case 3:
system("cls");
goto main;
break;
case 4:
return 0;
break;
default:
break;
}
return 0;
}
小弟使用的 是TC++3.0集成环境 由于上面源代码是 用VC++编写出来的 头文件 #include "stdafx.h" 总是显示 找不到我也找了相关的帖子看过的可还是得不到好的解决 ;删除#include "stdafx.h" 之后 又是显示 #include <windows.h> #include <winbase.h> 找不到 实在是不知道该怎么办了 于是才想到了到CSDN上面来求救 希望那位好心人能够帮我看看啊 绝对不耽误你们超过10分钟的时间撒 因为我知道CDSN上面的都是高手
有意相助的可联系我QQ:317817274 或者我 邮箱:xc0910@163.com
再次拜谢啊!!
...全文
803 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
harbincampus 2007-04-25
  • 打赏
  • 举报
回复
你可以用mingw这个编译器,用google就能搜到,很好用的
harbincampus 2007-04-25
  • 打赏
  • 举报
回复
老兄搜的这个程序一点都不稳定,存在漏洞
todototry 2007-04-25
  • 打赏
  • 举报
回复
mark
ini
okokok
fohonet 2007-04-25
  • 打赏
  • 举报
回复
你什么时候能发达啊 ?别让我等 等苦了!
benben_TBAG 2007-04-25
  • 打赏
  • 举报
回复
呵呵 先谢谢大家的鼎力相助啊 今天我是一只菜鸟 我是一个小喽罗 但是 等我以后发达了起来 一定不会忘掉大家曾经的热心和帮助的```
jixingzhong 2007-04-25
  • 打赏
  • 举报
回复
电子词典源程序
http://bbs.kingsoft.net/viewthread.php?tid=373958&sid=hpWv9W
lidongri 2007-04-24
  • 打赏
  • 举报
回复
//int ret=GetPrivateProfileString(buffer,temp,0,result,100,"./date.ini");
--
这个函数是windows.h定义的,用来读取ini 文件
如果不使用的话,可以去掉

#include <stdio.h>
#include <malloc.h>
#include <process.h>
就可以了
jixingzhong 2007-04-24
  • 打赏
  • 举报
回复
自己实现可以参看这个:

读取INI文件的函数(C语言)


/*
* File: inifile.h
* Read INI File
*/
#ifndef _INIFILE_H_
#define _INIFILE_H_

#include
#include

/*
* char* GetInitKey(FileName, Section, Key)
* Return Key=>Value
* Ex:
*
* + [config]
* + dbhost=localhost
*
* strcpy(dbhost,GetInitKey("config.ini", "config", "dbhost"));
*/
char * GetInitKey(char *filename, char *title,char *key)
{
FILE * fp;
char tmpLine[1024];
int rtnval;
int i = 0;
int flag = 0;
char * tmp;
static char tmpstr[1024];

if ((fp = fopen( filename, "r")) == NULL )
{
return "have no such file";
}
while (!feof(fp))
{
rtnval = fgetc( fp );
if ( rtnval == EOF )
{
break;
}
else
{
tmpLine[i++] = rtnval;
}
if ( rtnval == '\n')
{
tmpLine[--i]=0;
i = 0;
tmp = strchr(tmpLine, '=');

if (( tmp != NULL )&&(flag == 1))
{
if (strstr(tmpLine,key)!=NULL)
{
strcpy ( tmpstr, tmp + 1 );
fclose ( fp );
return tmpstr;
}
}
else
{
strcpy(tmpstr,"[");
strcat(tmpstr,title);
strcat(tmpstr,"]");
if (strcmp(tmpstr,tmpLine)==0)
{
flag = 1;
}
}

}
}
fclose ( fp );
return "";
}
#endif //_INIFILE_H_

使用方法:

char dbhost[20];
strcpy(dbhost,GetInitKey("config.ini", "config", "dbhost"));

ini文件内容

[config]
dbhost=localhost
jixingzhong 2007-04-24
  • 打赏
  • 举报
回复
int ret=GetPrivateProfileString(buffer,temp,0,result,100,"./date.ini");

int ret=WritePrivateProfileString(buffer,temp,result,"./date.ini");

这里调用了 WIN API,
把它们修改掉 ~

要么自己写一个读写 ini 文件的函数;
要么使用VC编译这个程序吧。
jixingzhong 2007-04-24
  • 打赏
  • 举报
回复
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <malloc.h>
#include <winbase.h>
#include <process.h>

==》
#include <stdio.h>
#include <stdlib.h>

其他头文件都不要 include 了
benben_TBAG 2007-04-24
  • 打赏
  • 举报
回复
有能帮忙的真的要说下 谢谢啊!!!

69,393

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧