找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 8200|回復(fù): 6
打印 上一主題 下一主題
收起左側(cè)

用c語言編寫的QQ程序,能實(shí)現(xiàn)注冊,登陸,聊天等操作

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:251514 發(fā)表于 2017-11-20 17:14 | 只看該作者 |只看大圖 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
附件是用c語言編寫的QQ程序,能夠?qū)崿F(xiàn)注冊,登陸,聊天等操作。



QQ源程序如下:
  1. #include "./inc/global.h"
  2. int sockfd;
  3. int flag = 0;
  4. void menu()
  5. {
  6.         printf("1: login\n");
  7.         printf("2: register\n");
  8.         printf("0: help\n");
  9. }
  10. void menu1()
  11. {
  12.         printf("1: chat\n");
  13.         printf("2: exit\n");
  14. }
  15. int login()
  16. {
  17.         struct user q;
  18.     char buf[128] = {0};
  19.         printf("please input name\n");
  20.         scanf("%s",q.name);
  21.         printf("please input passwd\n");
  22. pw:
  23.         scanf("%s",q.passwd);
  24.         strcat(buf,"login[        DISCUZ_CODE_0        ]quot;);
  25.         strcat(buf,q.name);
  26.         strcat(buf,"[        DISCUZ_CODE_0        ]quot;);
  27.         strcat(buf,q.passwd);
  28.         write(sockfd,(void *)buf,strlen(buf));
  29.         memset(buf,0,128);
  30.         read(sockfd,(void *)buf,128);
  31.         if(strcmp(buf,"0") == 0)
  32.         {
  33.                 printf("login success\n");
  34.                 return 0;
  35.         }
  36.         if(strcmp(buf,"1") == 0)
  37.         {
  38.                 printf("user name is not exist,please register\n");
  39.                 return -1;
  40.         }
  41.         if(strcmp(buf,"2") == 0)
  42.         {
  43.                 printf("user passwd is error,please input passwd\n");
  44.         memset(buf,0,128);
  45.                 memset(q.passwd,0,32);
  46.                 goto pw;
  47.         }

  48. }
  49. void client_register_user()
  50. {
  51.         char buf[128] = {0};
  52.         struct user q = {0};
  53. us:
  54.         printf("please input register name\n");
  55.         scanf("%s",q.name);
  56.         printf("please input register passwd\n");
  57.         scanf("%s",q.passwd);
  58.         strcat(buf,"register[        DISCUZ_CODE_0        ]quot;);
  59.         strcat(buf,q.name);
  60.         strcat(buf,"[        DISCUZ_CODE_0        ]quot;);
  61.         strcat(buf,q.passwd);
  62.         write(sockfd,(void *)buf,strlen(buf));
  63.         memset(buf,0,128);
  64.         read(sockfd,(void *)buf,128);
  65.         if(strcmp(buf,"0") == 0)
  66.         {
  67.                 printf("register success,please login\n");
  68.                 return ;
  69.         }
  70.         if(strcmp(buf,"1") == 0)
  71.         {
  72.                 printf("user name is exist,please register\n");
  73.                 memset(buf,0,128);
  74.                 memset(q.name,0,32);
  75.                 memset(q.passwd,0,32);
  76.                 goto us;
  77.         }
  78. }
  79. void display_user(char *p)
  80. {
  81.         int i;
  82.         i = 1;
  83.         while(1)
  84.         {
  85.                 if(*p == '\0')
  86.                         break;
  87. …………
  88. …………
  89. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
xitong_eighteen_3.rar (21.5 KB, 下載次數(shù): 43)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂1 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:252134 發(fā)表于 2017-11-23 20:13 | 只看該作者
贊一個(gè),不容易
回復(fù)

使用道具 舉報(bào)

板凳
ID:277402 發(fā)表于 2018-1-18 15:19 | 只看該作者
不容易
回復(fù)

使用道具 舉報(bào)

地板
ID:279131 發(fā)表于 2018-1-24 16:26 | 只看該作者
贊一個(gè),不容易
回復(fù)

使用道具 舉報(bào)

5#
ID:99130 發(fā)表于 2018-5-12 16:11 | 只看該作者
想知道怎么用
回復(fù)

使用道具 舉報(bào)

6#
ID:1050548 發(fā)表于 2023-7-18 09:26 | 只看該作者
能裝手機(jī)上面不
回復(fù)

使用道具 舉報(bào)

7#
ID:149799 發(fā)表于 2023-7-18 10:21 | 只看該作者
能裝手機(jī)上面不,想知道怎么用.
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表