脚本文件2

#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
using namespace std;
char tt[100];
void GetChar (const char* buf,char* begin,char* end)
{
    char* temp = new char[1000];
    strcpy(temp,buf);//拷贝给temp

    while(*temp != NULL)
    {
    if(*temp == *begin)
    {
        char* bt = temp;
        while(*bt != NULL)
        {
            if(*bt == *end)
            {
                temp++;
                temp++;
                *bt = '\0';
                strcpy(tt,temp);
            }
            else
            {
                bt++;
            }
        }
    }
    else
    {
        temp++;
    }
    }
}

char bbb[1000];
void GetCharT(const char* buf,int value)//value是第几段的{}
{
    char* Temp = new char[1000];
    strcpy(Temp,buf);
    char c[1];
    itoa(value,c,10);//把int转为char
    while(*Temp != NULL)
    {
AA:
        if(*Temp == c[0])
        {
            char* nTemp = Temp;
            nTemp ++;
            if(*nTemp == 'M')
            {
                //找到了头
                while(nTemp != NULL)
                {
                    if(*nTemp == ')')
                    {
                        *nTemp = '\0';
                        strcpy(bbb,Temp);
                        return;
                    }
                    else
                    {
                        nTemp ++;
                    }
                }
            }
            else
            {
                Temp++;
                goto AA;//不是头,继续找
            }
        }
        else
        {
            Temp++;
        }
    }

}

class student
{
public:
    student(){}
    ~student(){}
    char* _name;
    int _Lv;
    float _money;
    int _hp;
    int _Exp;
};
void main()
{
    FILE* pFile = NULL;
    pFile = fopen("Test.txt","r");
    char buf[100];
    memset(buf,0,100);

    student zs;
    map<string,student*> mapClass;
    mapClass["1"] = &zs;

    fread(buf,1,100,pFile);
    cout<<"读取当前硬盘上的数据是:"<<buf<<endl;

    GetChar(buf,"M","/");
//    cout<<"名字是:"<<tt<<endl;
    zs._name = new char[10];
    strcpy(zs._name,tt);


    GetChar(buf,"D","/");
//    cout<<"等级是:"<<tt<<endl;
    zs._Lv = atoi(tt);

    GetChar(buf,"J","/");
//    cout<<"金钱是:"<<tt<<endl;
    zs._money = atoi(tt);

    GetChar(buf,"H","/");
//    cout<<"HP是:"<<tt<<endl;
    zs._hp = atoi(tt);

    GetChar(buf,"E","/");
//    cout<<"经验是:"<<tt<<endl;
    zs._Exp = atoi(tt);


    //查找第2个账户
    GetCharT(buf,2);//结果保存在bbb里面
    student ls;
    mapClass["2"] = &ls;

    GetChar(bbb,"M","/");
//    cout<<"名字是:"<<tt<<endl;
    ls._name = new char[10];
    strcpy(ls._name,tt);


    GetChar(bbb,"D","/");
//    cout<<"等级是:"<<tt<<endl;
    ls._Lv = atoi(tt);

    GetChar(bbb,"J","/");
//    cout<<"金钱是:"<<tt<<endl;
    ls._money = atoi(tt);

    GetChar(bbb,"H","/");
//    cout<<"HP是:"<<tt<<endl;
    ls._hp = atoi(tt);

    GetChar(bbb,"E","/");
//    cout<<"经验是:"<<tt<<endl;
    ls._Exp = atoi(tt);

    cout<<endl;
    for(int i = 0; i<mapClass.size();i++)
    {
        cout<<"当前账户第"<<(i+1)<<"个账户==="<<endl;

        int Temp = (i+1);
        itoa(Temp,tt,10);
        cout<<"名字是"<<mapClass[tt]->_name<<" ";
        cout<<"等级是"<<mapClass[tt]->_Lv<<" ";
        cout<<"金钱是"<<mapClass[tt]->_money<<" ";
        cout<<"HP是"<<mapClass[tt]->_hp<<" ";
        cout<<"经验是"<<mapClass[tt]->_Exp<<" ";
        cout<<endl;
        cout<<endl;
    }


    cout<<"读取硬盘数据完毕"<<endl;
    fclose(pFile);
    system("pause");
}

将Test.txt中的内容分类输出

(1M:张三 /D:21 /J:3000 /H:2100 /E:98989898/)(2M:李四 /D:18 /J:1500 /H:1100 /E:2289898/)


用VS2010可以正常的输出;但是当用QT5时,第二个账户输出有误,QT不知道怎么弄的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
pcblogocreator脚本文件是一种基于PC环境的自动化脚本文件,用于创建个人博客网站。该脚本提供了一系列的命令和功能,使用户能够快速、简便地搭建和管理个人博客。 首先,pcblogocreator脚本文件提供了一个用户友好的命令行界面,让用户能够通过简单的命令完成博客的创建和管理。用户只需按照脚本的提示,输入相应的指令和参数,就能够完成博客的配置和设置。 其次,pcblogocreator脚本文件内置了一些常用的博客模板和主题,用户可以根据自己的喜好选择。这些模板和主题不仅外观漂亮、风格多样,还具有响应式设计,适应不同设备的屏幕大小,提供更好的用户体验。 此外,pcblogocreator脚本文件还包含了一些常见的组件和插件,如评论系统、标签管理、社交媒体分享等,以提供更丰富的博客功能。用户可以根据自己的需求,选择安装和配置相应的组件和插件,以扩展博客的功能和交互性。 最后,pcblogocreator脚本文件还提供了一些便捷的命令,用于博客的部署和发布。用户只需执行相应的命令,即可将博客部署到云服务器或者其他公共主机上,让更多的人访问和阅读。 总的来说,pcblogocreator脚本文件是一种强大而方便的工具,用于快速搭建和管理个人博客。它能够帮助用户节省时间和精力,让用户更专注于博客内容的创作和分享。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值