資源簡介
是安徽工業大學的Linux程序設計這門課的課程設計,實現qq通信的功能的源碼,希望對大家有所幫助。

代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#define?MAX_BUF_SIZE?1024
struct?message?{
char?from[20];
????????char?passwd[20];
????????char?to[20];
char?buf[MAX_BUF_SIZE];
};
char?buf1[MAX_BUF_SIZE];
???????????int?i;
??char?passwd1[20];
??char?name1[20];
void?udp_client(int?sockfd?struct?sockaddr_in?*addr)
{
int?ni;
int?pid;
struct?message?sendmsg;
struct?message?rcvmsg;
char?sel;
????????system(“clear“);
printf(“========炫聊1.0========\n“);
printf(“====??小組成員:???====\n“);
printf(“=????組長:王義龍?????=\n“);
printf(“=????成員:張??建?????=\n“);
printf(“=????成員:歐陽露?????=\n“);
printf(“=????成員:尹??艷?????=\n“);
printf(“=????組長:張文天?????=\n“);
printf(“=??next??[ENTER]=>“);
?while(getchar()){
???????printf(“press?any?key?to?next:“);
???????getchar();
???????system(“clear“);
???????system(“date“);
printf(“**0--login??1--registe?q--quit**\n>“);
????????scanf(“%c“&sel);
???????switch(sel)
???????{
????????case?‘0‘:
???????????printf(“user_name:“);
???????????scanf(“%s“sendmsg.from);
???????????printf(“password:“);
???????????scanf(“%s“sendmsg.passwd);
?????????strcpy(sendmsg.tosendmsg.from);
???strcpy(sendmsg.buf“login“);
???????????break;
????????case?‘1‘:
???????????printf(“new?user_name:“);
???????????scanf(“%s“sendmsg.from);
???????????printf(“new?password:“);
???????????scanf(“%s“sendmsg.passwd);
???????????printf(“again?new?password:“);
???????????scanf(“%s“passwd1);
??????????if(strcmp(passwd1sendmsg.passwd))
???????????{
?????????????printf(“please?input?the?same?passwd!\n“);
?????????????exit(0);
???????????}
???????????strcpy(sendmsg.tosendmsg.from);
???????????strcpy(sendmsg.buf“register“);
???????????break;
?????????case?‘q‘:
???????????exit(0);
?????????default:?
???????????printf(“錯誤的輸入!“);
???????????exit(0);
???????}
n?=?sendto(sockfd?(struct?message?*)&sendmsg?sizeof(struct?message)?0?(struct?sockadrr?*)addr?sizeof(struct?sockaddr));
n?=?recvfrom(sockfd?(struct?message?*)&rcvmsg?sizeof(struct?message)?0?NULL?NULL);
???????if(!strcmp(rcvmsg.buf“注冊成功!“))
???????{
?????????????printf(“%s\n“rcvmsg.buf);
?????????????continue;
???????}
???????if(!strcmp(rcvmsg.buf“登陸成功“))
???????{?
????????????system(“clear“);
????????????strcpy(name1rcvmsg.from);
????????????system(“date“);
????????????printf(“用戶:?%s?很高興您使用本軟件!\n“rcvmsg.from);
????????????printf(“規范須知:\n“);
????????????printf(“*?user_namemessage--send?the?message?to?user_name\n“);
????????????printf(“*?allmessage--send?the?message?to?all?online?users\n“);
????????????printf(“*?online--display?online?users?list\n“);
????????????printf(“*?exit--make?all?online?user?know?that?it?quit:\n“);
????????????printf(“**?‘’很重要,不能忘記,不能寫錯:\n“);
????????????break;
???????}
???????else
?????????{
????????????printf(“%s\n“rcvmsg.buf);
????????????continue;
?????????}
???}
???????if((pid?=?fork())?0)?
???????{
??perror(“create?process?error!\n“);
??exit(0);
???????}
for(;;){
???if(
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4838??2009-06-30?15:46??linux課程設計\qqc2.c
?????文件???????6598??2009-06-30?09:39??linux課程設計\qqs.c
?????文件???????8956??2009-06-30?17:11??linux課程設計\qqs1.c
?????目錄??????????0??2009-06-30?22:14??linux課程設計
-----------?---------??----------?-----??----
????????????????20392????????????????????4
- 上一篇:微機原理及匯編語言課程設計_簡易電子琴
- 下一篇:CEGUI.txt
評論
共有 條評論