• 信箱通信功能增加(1)


    拓展功能

    增加了-h查看历史记录(5条),为收到的消息打标签,-f按标签查找信息(100个标签)

    为收到的消息打标签

    struct tags
    	{
    	char ch[10];
    	char flag[10];
    	};
    

    定义结构体存放标志和信息。ch[10]存放信息,flag[10]存放标志

    if(c=='r'&&add1[i].flag==1)//接收信息
    		{
    		P(idAr);
    		P(Asem);
    		printf("port a receive mail %s sucessfully
    ",add1[i].ch);
    		add1[i].flag=0;
    		V(Asem);
    		V(idBs);
    		printf("would you want to give this mail a tag?(yes/no)
    ");
    		scanf("%s",fflag);
    		if(strcmp(fflag,"yes")==0)
    		{
    			strcpy(tag[z].ch,add1[i].ch);
    			printf("please input the tag:
    ");
    			scanf("%s",w);
    			strcpy(tag[z].flag,w);
    			z=(z+1)%100;
    		}
    		i=(i+1)%5;
    		}
    

    在接收消息的同时询问是否打标签。

    -h查看历史记录

    else if(c=='h')//查找历史纪录(前5次收信)
    		{
    			int m=i-1;	
    			printf("please input the number:
    ");
    			scanf("%d",&number);
    			if(number>=5)
    			{
    				printf("can't find
    ");
    			}
    			else
    			{	
    				if(number-i>=0)
    					printf("the mail is %s
    ",add1[i-number].ch);
    			        else
    					printf("the mail is %s
    ",add1[i-number+5].ch);
    			}
    		}
    

    输入数字查询前几次收信

    -f按标签查找信息

    else if(c=='f')//按tag查找信息
    		{
    			printf("please input the tag you want to find
    ");
    			char tag1[10];
    			scanf("%s",tag1);
    			int i1=0,findflag=0;
    			while(i1<=z)
    			{
    				if(strcmp(tag1,tag[i1].flag)==0)
    				{
    					printf("the mail is %s
    ",tag[i1].ch);
    					findflag=1;
    					break;
    				}
    				i1++;
    			}
    			if(findflag==0)
    			{
    				printf("can't find
    ");
    			}
    		}
    

    ###功能演示 ![](https://images2018.cnblogs.com/blog/1475969/201809/1475969-20180903211254446-1803710763.png)
    **遇到的问题[here](https://www.cnblogs.com/zzc2018/p/9580714.html) 完整代码[here](https://github.com/anmui/zzc2018)**
  • 相关阅读:
    2017.5.11下午学习内容
    windows消息和消息队列
    探索Win32系统之窗口类(转载)
    WinMain函数详解(转载)
    Ajax爬取实战头条街拍美图
    Ajax实战微博
    Ajax请求分析实战
    ubuntu 安装rails
    ubuntu Thunderbird 接收邮件显示乱码的问题排除
    ubuntu 开机挂载windows分区
  • 原文地址:https://www.cnblogs.com/zzc2018/p/9581066.html
Copyright © 2020-2023  润新知