脚本文件1

读取Test.txt文件内容:

<M:张三/D:21/J:3000/H:2100/E:98989898/-->

#include <iostream>
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++;
    }
    }
}
//#include <stdio.h>
void main()
{
    FILE* pFile = NULL;
    pFile = fopen("Test.txt","r");
    char buf[100];
    memset(buf,0,100);

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

    GetChar(buf,"M","/");
    cout<<"名字是:"<<tt<<endl;

    GetChar(buf,"D","/");
    cout<<"等级是:"<<tt<<endl;

    GetChar(buf,"J","/");
    cout<<"金钱是:"<<tt<<endl;

    GetChar(buf,"H","/");
    cout<<"HP是:"<<tt<<endl;

    GetChar(buf,"E","/");
    cout<<"经验是:"<<tt<<endl;

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值